Skip to content

Commit

Permalink
[OPENVINO CODE] Added Fill-in-the-middle(FIM) support (#848)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
kumarijy authored Feb 6, 2024
1 parent 6aa1117 commit a7293b4
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 12 deletions.
18 changes: 18 additions & 0 deletions modules/openvino_code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ OpenVINO Code provides the following features:

- Inline Code Completion
- Summarization via Docstring
- Fill in the Middle Mode

## Working with Extension

Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions modules/openvino_code/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 40 additions & 5 deletions modules/openvino_code/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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."
},
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions modules/openvino_code/shared/features.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export enum Features {
CODE_COMPLETION = 'Code Completion',
SUMMARIZATION = 'Summarization',
FIM = 'Fill-in-the-middle',
}
10 changes: 7 additions & 3 deletions modules/openvino_code/shared/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, ModelId> = {
[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, Features[]> = {
[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],
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export function OverviewSection(): JSX.Element {
OpenVINO Code provides the following features:
<ul>
<li>Inline Code Completion</li>
<li>Summarization via docstring</li>
<li>Summarization via docstring</li>
<li>Fill in the Middle Mode</li>
</ul>
To use OpenVINO Code please start the server.
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const options: SelectOptionProps<ModelName>[] = [
{ 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 {
Expand Down Expand Up @@ -34,7 +35,7 @@ export const ModelSelect = ({
disabled={disabled}
onChange={(value) => onChange(value)}
></Select>
{isServerStopped && <span>Supported Featues: {supportedFeatures.join(', ')}</span>}
{isServerStopped && <span>Supported Features: {supportedFeatures.join(', ')}</span>}
</>
);
};

0 comments on commit a7293b4

Please sign in to comment.