Skip to content

Commit 638cf7a

Browse files
authored
SDK - patch opensourceai for latest models (#1541)
1 parent fa9639f commit 638cf7a

File tree

5 files changed

+23
-108
lines changed

5 files changed

+23
-108
lines changed

pgml-sdks/pgml/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pgml-sdks/pgml/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pgml"
3-
version = "1.1.0"
3+
version = "1.1.1"
44
edition = "2021"
55
authors = ["PosgresML <team@postgresml.org>"]
66
homepage = "https://postgresml.org/"

pgml-sdks/pgml/javascript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pgml",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Open Source Alternative for Building End-to-End Vector Search Applications without OpenAI & Pinecone",
55
"keywords": [
66
"postgres",

pgml-sdks/pgml/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "maturin"
55
[project]
66
name = "pgml"
77
requires-python = ">=3.7"
8-
version = "1.1.0"
8+
version = "1.1.1"
99
description = "Python SDK is designed to facilitate the development of scalable vector search applications on PostgreSQL databases."
1010
authors = [
1111
{name = "PostgresML", email = "team@postgresml.org"},

pgml-sdks/pgml/src/open_source_ai.rs

Lines changed: 19 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -35,112 +35,40 @@ fn try_model_nice_name_to_model_name_and_parameters(
3535
"meta-llama/Meta-Llama-3-8B-Instruct" => Some((
3636
"meta-llama/Meta-Llama-3-8B-Instruct",
3737
serde_json::json!({
38-
"task": "conversationa",
38+
"task": "conversational",
3939
"model": "meta-llama/Meta-Llama-3-8B-Instruct"
4040
})
4141
.into(),
4242
)),
43-
44-
"mistralai/Mistral-7B-Instruct-v0.1" => Some((
45-
"mistralai/Mistral-7B-Instruct-v0.1",
46-
serde_json::json!({
47-
"task": "conversational",
48-
"model": "mistralai/Mistral-7B-Instruct-v0.1",
49-
"device_map": "auto",
50-
"torch_dtype": "bfloat16"
51-
})
52-
.into(),
53-
)),
54-
55-
"TheBloke/Llama-2-7B-Chat-GPTQ" => Some((
56-
"TheBloke/Llama-2-7B-Chat-GPTQ",
57-
serde_json::json!({
58-
"task": "conversational",
59-
"model": "TheBloke/Llama-2-7B-Chat-GPTQ",
60-
"device_map": "auto",
61-
"revision": "main"
62-
})
63-
.into(),
64-
)),
65-
66-
"teknium/OpenHermes-2.5-Mistral-7B" => Some((
67-
"teknium/OpenHermes-2.5-Mistral-7B",
68-
serde_json::json!({
69-
"task": "conversational",
70-
"model": "teknium/OpenHermes-2.5-Mistral-7B",
71-
"device_map": "auto",
72-
"torch_dtype": "bfloat16"
73-
})
74-
.into(),
75-
)),
76-
77-
"Open-Orca/Mistral-7B-OpenOrca" => Some((
78-
"Open-Orca/Mistral-7B-OpenOrca",
79-
serde_json::json!({
80-
"task": "conversational",
81-
"model": "Open-Orca/Mistral-7B-OpenOrca",
82-
"device_map": "auto",
83-
"torch_dtype": "bfloat16"
84-
})
85-
.into(),
86-
)),
87-
88-
"Undi95/Toppy-M-7B" => Some((
89-
"Undi95/Toppy-M-7B",
90-
serde_json::json!({
91-
"model": "Undi95/Toppy-M-7B",
92-
"device_map": "auto",
93-
"torch_dtype": "bfloat16"
94-
})
95-
.into(),
96-
)),
97-
98-
"Undi95/ReMM-SLERP-L2-13B" => Some((
99-
"Undi95/ReMM-SLERP-L2-13B",
43+
"meta-llama/Meta-Llama-3-70B-Instruct" => Some((
44+
"meta-llama/Meta-Llama-3-70B-Instruct",
10045
serde_json::json!({
101-
"model": "Undi95/ReMM-SLERP-L2-13B",
102-
"device_map": "auto",
103-
"torch_dtype": "bfloat16"
46+
"task": "conversational",
47+
"model": "meta-llama/Meta-Llama-3-70B-Instruct"
10448
})
10549
.into(),
10650
)),
107-
108-
"Gryphe/MythoMax-L2-13b" => Some((
109-
"Gryphe/MythoMax-L2-13b",
51+
"microsoft/Phi-3-mini-128k-instruct" => Some((
52+
"microsoft/Phi-3-mini-128k-instruct",
11053
serde_json::json!({
111-
"model": "Gryphe/MythoMax-L2-13b",
112-
"device_map": "auto",
113-
"torch_dtype": "bfloat16"
54+
"task": "conversational",
55+
"model": "microsoft/Phi-3-mini-128k-instruct"
11456
})
11557
.into(),
11658
)),
117-
118-
"PygmalionAI/mythalion-13b" => Some((
119-
"PygmalionAI/mythalion-13b",
59+
"mistralai/Mixtral-8x7B-Instruct-v0.1" => Some((
60+
"mistralai/Mixtral-8x7B-Instruct-v0.1",
12061
serde_json::json!({
121-
"model": "PygmalionAI/mythalion-13b",
122-
"device_map": "auto",
123-
"torch_dtype": "bfloat16"
62+
"task": "conversational",
63+
"model": "mistralai/Mixtral-8x7B-Instruct-v0.1"
12464
})
12565
.into(),
12666
)),
127-
128-
"deepseek-ai/deepseek-llm-7b-chat" => Some((
129-
"deepseek-ai/deepseek-llm-7b-chat",
67+
"mistralai/Mistral-7B-Instruct-v0.2" => Some((
68+
"mistralai/Mistral-7B-Instruct-v0.2",
13069
serde_json::json!({
131-
"model": "deepseek-ai/deepseek-llm-7b-chat",
132-
"device_map": "auto",
133-
"torch_dtype": "bfloat16"
134-
})
135-
.into(),
136-
)),
137-
138-
"Phind/Phind-CodeLlama-34B-v2" => Some((
139-
"Phind/Phind-CodeLlama-34B-v2",
140-
serde_json::json!({
141-
"model": "Phind/Phind-CodeLlama-34B-v2",
142-
"device_map": "auto",
143-
"torch_dtype": "bfloat16"
70+
"task": "conversational",
71+
"model": "mistralai/Mistral-7B-Instruct-v0.2"
14472
})
14573
.into(),
14674
)),
@@ -149,15 +77,6 @@ fn try_model_nice_name_to_model_name_and_parameters(
14977
}
15078
}
15179

152-
fn try_get_model_chat_template(model_name: &str) -> Option<&'static str> {
153-
match model_name {
154-
// Any Alpaca instruct tuned model
155-
"Undi95/Toppy-M-7B" | "Undi95/ReMM-SLERP-L2-13B" | "Gryphe/MythoMax-L2-13b" | "Phind/Phind-CodeLlama-34B-v2" => Some("{% for message in messages %}\n{% if message['role'] == 'user' %}\n{{ '### Instruction:\n' + message['content'] + '\n'}}\n{% elif message['role'] == 'system' %}\n{{ message['content'] + '\n'}}\n{% elif message['role'] == 'model' %}\n{{ '### Response:>\n' + message['content'] + eos_token + '\n'}}\n{% endif %}\n{% if loop.last and add_generation_prompt %}\n{{ '### Response:' }}\n{% endif %}\n{% endfor %}"),
156-
"PygmalionAI/mythalion-13b" => Some("{% for message in messages %}\n{% if message['role'] == 'user' %}\n{{ '<|user|>\n' + message['content'] + eos_token }}\n{% elif message['role'] == 'system' %}\n{{ '<|system|>\n' + message['content'] + eos_token }}\n{% elif message['role'] == 'model' %}\n{{ '<|model|>\n' + message['content'] + eos_token }}\n{% endif %}\n{% if loop.last and add_generation_prompt %}\n{{ '<|model|>' }}\n{% endif %}\n{% endfor %}"),
157-
_ => None
158-
}
159-
}
160-
16180
struct AsyncToSyncJsonIterator(std::pin::Pin<Box<dyn Stream<Item = anyhow::Result<Json>> + Send>>);
16281

16382
impl Iterator for AsyncToSyncJsonIterator {
@@ -265,9 +184,7 @@ mistralai/Mistral-7B-v0.1
265184
// TODO: Add n
266185

267186
let mut args = serde_json::json!({ "max_tokens": max_tokens, "temperature": temperature });
268-
if let Some(t) = chat_template
269-
.or_else(|| try_get_model_chat_template(&model_name).map(|s| s.to_string()))
270-
{
187+
if let Some(t) = chat_template {
271188
args.as_object_mut().unwrap().insert(
272189
"chat_template".to_string(),
273190
serde_json::to_value(t).unwrap(),
@@ -355,9 +272,7 @@ mistralai/Mistral-7B-v0.1
355272
// TODO: Add n
356273

357274
let mut args = serde_json::json!({ "max_tokens": max_tokens, "temperature": temperature });
358-
if let Some(t) = chat_template
359-
.or_else(|| try_get_model_chat_template(&model_name).map(|s| s.to_string()))
360-
{
275+
if let Some(t) = chat_template {
361276
args.as_object_mut().unwrap().insert(
362277
"chat_template".to_string(),
363278
serde_json::to_value(t).unwrap(),

0 commit comments

Comments
 (0)