From a7293b4b904b4b7264490615d40ada43ef923122 Mon Sep 17 00:00:00 2001 From: kumarijy <112030960+kumarijy@users.noreply.github.com> Date: Tue, 6 Feb 2024 09:07:45 -0800 Subject: [PATCH] [OPENVINO CODE] Added Fill-in-the-middle(FIM) support (#848) * Adding FIM support through deepseek-coder-1.3b-instruct and changed model names at FE * used ALL_CAPS for model name consistency and replaced 7B with 1_3B * fixed frontend modelname * changed version to 0.0.8 * changed FIM tokens format in alignment with HF model deepseek-coder format * added README for adding Fill in the middle mode support and updated OverviewSection * removed int8 from decicoder-1b-openvino model name * added deepseek-coder int-8 model --- modules/openvino_code/README.md | 18 ++++++++ modules/openvino_code/package-lock.json | 4 +- modules/openvino_code/package.json | 45 ++++++++++++++++--- modules/openvino_code/shared/features.ts | 1 + modules/openvino_code/shared/model.ts | 10 +++-- .../OverviewSection/OverviewSection.tsx | 3 +- .../ServerSection/ModelSelect/ModelSelect.tsx | 3 +- 7 files changed, 72 insertions(+), 12 deletions(-) diff --git a/modules/openvino_code/README.md b/modules/openvino_code/README.md index cd5f5dc57..448dbcc35 100644 --- a/modules/openvino_code/README.md +++ b/modules/openvino_code/README.md @@ -8,6 +8,7 @@ OpenVINO Code provides the following features: - Inline Code Completion - Summarization via Docstring +- Fill in the Middle Mode ## Working with Extension @@ -48,6 +49,23 @@ You can select the desired type of quotes in the extension settings. The model can generate docstring in Code Completion mode, but in this case it is impossible to control the result. In the docstring generation mode, various popular templates are available in the settings that will guide the model output. +### Fill in the Middle Mode + + +1. Create a new Python file or open an existing one. +1. Type `def main():` or place the cursor where you'd like middle text to be generated. +1. Press the keyboard shortcut `Ctrl+Alt+Space` (`Cmd+Alt+Space` for macOS) or click the `Generate Code Completion` button located in the side panel. +1. You can select the text then generate the related code. +1. You may also right-click on "Generate Inline Code Completion In New Tab" to generate code in a new tab. +1. Use the `Tab` key to accept the entire suggestion or `Ctrl`+`Right Arrow` to accept it word by word. To decline the suggestion, press `Esc`. + +You can customize the length of the generated code by adjusting `Max New Tokens` and `Min New Tokens` parameters in the extension settings. +The number of generated tokens is also influenced by the `Server Request Timeout` setting. + +Fill in the middle mode brings in advanced code completion capabilities supporting fill-in-the-blank task, supporting project-level code completion and infilling tasks. + +To enable fill in the middle mode, check the `Fill In The Middle Mode` checkbox in the extension settings. + ### Monitoring Extension Output To examine the input and output from the code generation API, follow these steps: diff --git a/modules/openvino_code/package-lock.json b/modules/openvino_code/package-lock.json index 89fa7c2e1..0b2521f49 100644 --- a/modules/openvino_code/package-lock.json +++ b/modules/openvino_code/package-lock.json @@ -1,12 +1,12 @@ { "name": "openvino-code-completion", - "version": "0.0.6", + "version": "0.0.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "openvino-code-completion", - "version": "0.0.6", + "version": "0.0.8", "license": "https://github.com/openvinotoolkit/openvino_contrib/blob/master/LICENSE", "workspaces": [ "side-panel-ui" diff --git a/modules/openvino_code/package.json b/modules/openvino_code/package.json index ee16aa4b0..d3dd85362 100644 --- a/modules/openvino_code/package.json +++ b/modules/openvino_code/package.json @@ -1,7 +1,7 @@ { "publisher": "OpenVINO", "name": "openvino-code-completion", - "version": "0.0.6", + "version": "0.0.8", "displayName": "OpenVINO Code Completion", "description": "VSCode extension for AI code completion with OpenVINO", "icon": "media/logo.png", @@ -190,11 +190,12 @@ "openvinoCode.model": { "order": 0, "type": "string", - "default": "codet5p-220m-py", + "default": "code-t5", "enum": [ - "codet5p-220m-py", - "decicoder-1b-openvino-int8", - "stablecode-completion-3b-int8" + "code-t5", + "decicoder-1b-openvino", + "stablecode-completion", + "deepseek-coder" ], "description": "Which model to use for code generation." }, @@ -229,6 +230,40 @@ "default": "false", "description": "When checked inline complention will be generated in streaming mode" }, + "openvinoCode.fillInTheMiddleMode": { + "order": 4, + "type": "boolean", + "default": "false", + "description": + "When checked, text before (above) and after (below) the cursor will be used for completion generation. When unckecked, only text before (above) the cursor will be used." + }, + "openvinoCode.startToken": { + "order": 7, + "type": "string", + "default": "< |fim_begin| >", + "description": + "String that is sent to server is in format: `{startToken}{text above cursor}{middleToken}{text below cursor if fillInTheMiddleMode=true}{endToken}`. Leave `startToken`, `middleToken`, or `endToken` empty if there is no special token for those placements." + }, + "openvinoCode.middleToken": { + "order": 8, + "type": "string", + "default": "<|fim▁hole|>", + "description": + "String that is sent to server is in format: `{startToken}{text above cursor}{middleToken}{text below cursor if fillInTheMiddleMode=true}{endToken}`. Leave `startToken`, `middleToken`, or `endToken` empty if there is no special token for those placements." + }, + "openvinoCode.endToken": { + "order": 9, + "type": "string", + "default": "<|fim▁end|>", + "description": + "String that is sent to server is in format: `{startToken}{text above cursor}{middleToken}{text below cursor if fillInTheMiddleMode=true}{endToken}`. Leave `startToken`, `middleToken`, or `endToken` empty if there is no special token for those placements." + }, + "openvinoCode.stopToken": { + "order": 10, + "type": "string", + "default": "<|endoftext|>", + "description": "(Optional) Stop token." + }, "openvinoCode.temperature": { "order": 4, "type": "number", diff --git a/modules/openvino_code/shared/features.ts b/modules/openvino_code/shared/features.ts index d376256b2..48a406c77 100644 --- a/modules/openvino_code/shared/features.ts +++ b/modules/openvino_code/shared/features.ts @@ -1,4 +1,5 @@ export enum Features { CODE_COMPLETION = 'Code Completion', SUMMARIZATION = 'Summarization', + FIM = 'Fill-in-the-middle', } diff --git a/modules/openvino_code/shared/model.ts b/modules/openvino_code/shared/model.ts index 8d642c39a..e08930ecc 100644 --- a/modules/openvino_code/shared/model.ts +++ b/modules/openvino_code/shared/model.ts @@ -4,22 +4,26 @@ enum ModelId { CODE_T5_220M = 'Salesforce/codet5p-220m-py', DECICODER_1B_OPENVINO_INT8 = 'chgk13/decicoder-1b-openvino-int8', STABLECODE_COMPLETION_ALPHA_3B_4K_OPENVINO_INT8 = 'chgk13/stablecode-completion-alpha-3b-4k-openvino-int8', + DEEPSEEK_CODER_1_3B = 'kumarijy/deepseek-coder-1_3b-instruct-openvino-int8', } export enum ModelName { - CODE_T5_220M = 'codet5p-220m-py', - DECICODER_1B_OPENVINO_INT8 = 'decicoder-1b-openvino-int8', - STABLECODE_COMPLETION_ALPHA_3B_4K_OPENVINO_INT8 = 'stablecode-completion-3b-int8', + CODE_T5_220M = 'code-t5', + DECICODER_1B_OPENVINO_INT8 = 'decicoder-1b-openvino', + STABLECODE_COMPLETION_ALPHA_3B_4K_OPENVINO_INT8 = 'stablecode-completion', + DEEPSEEK_CODER_1_3B = 'deepseek-coder', } export const MODEL_NAME_TO_ID_MAP: Record = { [ModelName.CODE_T5_220M]: ModelId.CODE_T5_220M, [ModelName.DECICODER_1B_OPENVINO_INT8]: ModelId.DECICODER_1B_OPENVINO_INT8, [ModelName.STABLECODE_COMPLETION_ALPHA_3B_4K_OPENVINO_INT8]: ModelId.STABLECODE_COMPLETION_ALPHA_3B_4K_OPENVINO_INT8, + [ModelName.DEEPSEEK_CODER_1_3B]: ModelId.DEEPSEEK_CODER_1_3B, }; export const MODEL_SUPPORTED_FEATURES: Record = { [ModelName.CODE_T5_220M]: [Features.CODE_COMPLETION], [ModelName.DECICODER_1B_OPENVINO_INT8]: [Features.CODE_COMPLETION, Features.SUMMARIZATION], [ModelName.STABLECODE_COMPLETION_ALPHA_3B_4K_OPENVINO_INT8]: [Features.CODE_COMPLETION, Features.SUMMARIZATION], + [ModelName.DEEPSEEK_CODER_1_3B]: [Features.CODE_COMPLETION, Features.SUMMARIZATION, Features.FIM], }; diff --git a/modules/openvino_code/side-panel-ui/src/components/sections/OverviewSection/OverviewSection.tsx b/modules/openvino_code/side-panel-ui/src/components/sections/OverviewSection/OverviewSection.tsx index cf699f713..a785538eb 100644 --- a/modules/openvino_code/side-panel-ui/src/components/sections/OverviewSection/OverviewSection.tsx +++ b/modules/openvino_code/side-panel-ui/src/components/sections/OverviewSection/OverviewSection.tsx @@ -7,7 +7,8 @@ export function OverviewSection(): JSX.Element { OpenVINO Code provides the following features: To use OpenVINO Code please start the server. diff --git a/modules/openvino_code/side-panel-ui/src/components/sections/ServerSection/ModelSelect/ModelSelect.tsx b/modules/openvino_code/side-panel-ui/src/components/sections/ServerSection/ModelSelect/ModelSelect.tsx index 16746a7c7..06a1bc9ff 100644 --- a/modules/openvino_code/side-panel-ui/src/components/sections/ServerSection/ModelSelect/ModelSelect.tsx +++ b/modules/openvino_code/side-panel-ui/src/components/sections/ServerSection/ModelSelect/ModelSelect.tsx @@ -7,6 +7,7 @@ const options: SelectOptionProps[] = [ { value: ModelName.CODE_T5_220M }, { value: ModelName.DECICODER_1B_OPENVINO_INT8 }, { value: ModelName.STABLECODE_COMPLETION_ALPHA_3B_4K_OPENVINO_INT8 }, + { value: ModelName.DEEPSEEK_CODER_1_3B }, ]; interface ModelSelectProps { @@ -34,7 +35,7 @@ export const ModelSelect = ({ disabled={disabled} onChange={(value) => onChange(value)} > - {isServerStopped && Supported Featues: {supportedFeatures.join(', ')}} + {isServerStopped && Supported Features: {supportedFeatures.join(', ')}} ); };