From f31b60409c5215d879e653feb279094da4cf73ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20J=C3=B8rgensen?= Date: Thu, 15 Feb 2024 19:04:27 +0100 Subject: [PATCH 1/2] add new openapi embeddings (#861) --- docs/docs/walkthroughs/codebase-embeddings.md | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/docs/docs/walkthroughs/codebase-embeddings.md b/docs/docs/walkthroughs/codebase-embeddings.md index e3dadf9ea..b06c246ee 100644 --- a/docs/docs/walkthroughs/codebase-embeddings.md +++ b/docs/docs/walkthroughs/codebase-embeddings.md @@ -96,13 +96,42 @@ We also support other methods of generating embeddings, which can be configured ### OpenAI -OpenAI's [ada-002 embeddings](https://platform.openai.com/docs/guides/embeddings) are high dimensional embeddings that give great performance on both text and code. +OpenAI's [embeddings](https://platform.openai.com/docs/guides/embeddings) are high dimensional embeddings that give great performance on both text and code. + +Configuration for text-embedding-3-small Model +The text-embedding-3-small model offers an outstanding balance between performance and efficiency, suitable for a versatile range of applications. ```json title="~/.continue/config.json" { "embeddingsProvider": { "provider": "openai", - "model": "text-embedding-ada-002", // optional, defaults to "text-embedding-ada-002" + "model": "text-embedding-3-small", + "apiBase": "" // optional, defaults to OpenAI's API + } +} +``` + +Configuration for text-embedding-3-large Model +For those requiring the highest level of embedding detail and precision, the text-embedding-3-large model is the better choice. + +```json title="~/.continue/config.json" +{ + "embeddingsProvider": { + "provider": "openai", + "model": "text-embedding-3-large", + "apiBase": "" // optional, defaults to OpenAI's API + } +} +``` + +Legacy Model Configuration +For certain scenarios, you may still find the text-embedding-ada-002 model relevant. Below is the configuration example: + +```json title="~/.continue/config.json" +{ + "embeddingsProvider": { + "provider": "openai", + "model": "text-embedding-ada-002", "apiBase": "" // optional, defaults to OpenAI's API } } From f95a54d9c29247680839129c54eae912ba5ca85d Mon Sep 17 00:00:00 2001 From: thirdmadman Date: Thu, 15 Feb 2024 19:05:57 +0100 Subject: [PATCH 2/2] fix: correct llama2TemplateMessages (#855) --- core/llm/templates/chat.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/core/llm/templates/chat.ts b/core/llm/templates/chat.ts index bb0945042..f9f748da3 100644 --- a/core/llm/templates/chat.ts +++ b/core/llm/templates/chat.ts @@ -1,6 +1,16 @@ import { ChatMessage } from "../.."; import { stripImages } from "../countTokens"; + +/** + * @description Template for LLAMA2 messages: + * + * [INST] <> + * {{ system_prompt }} + * <> + * + * {{ user_msg_1 }} [/INST] {{ model_answer_1 }} [INST] {{ user_msg_2 }} [/INST] {{ model_answer_2 }} [INST] {{ user_msg_3 }} [/INST] + */ function llama2TemplateMessages(msgs: ChatMessage[]): string { if (msgs.length === 0) { return ""; @@ -21,14 +31,9 @@ function llama2TemplateMessages(msgs: ChatMessage[]): string { } if (hasSystem) { - const systemMessage = ` - <> - ${msgs[0].content} - <> - - `; + const systemMessage = `<>\n ${msgs[0].content}\n<>\n\n`; if (msgs.length > 1) { - prompt += `[INST] ${systemMessage}${msgs[1].content} [/INST]`; + prompt += `[INST] ${systemMessage} ${msgs[1].content} [/INST]`; } else { prompt += `[INST] ${systemMessage} [/INST]`; return prompt; @@ -39,7 +44,7 @@ function llama2TemplateMessages(msgs: ChatMessage[]): string { if (msgs[i].role === "user") { prompt += `[INST] ${msgs[i].content} [/INST]`; } else { - prompt += msgs[i].content + " "; + prompt += msgs[i].content + "\n"; } }