Skip to content

Commit a7293b4

Browse files
authored
[OPENVINO CODE] Added Fill-in-the-middle(FIM) support (openvinotoolkit#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
1 parent 6aa1117 commit a7293b4

File tree

7 files changed

+72
-12
lines changed

7 files changed

+72
-12
lines changed

modules/openvino_code/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ OpenVINO Code provides the following features:
88

99
- Inline Code Completion
1010
- Summarization via Docstring
11+
- Fill in the Middle Mode
1112

1213
## Working with Extension
1314

@@ -48,6 +49,23 @@ You can select the desired type of quotes in the extension settings.
4849
The model can generate docstring in Code Completion mode, but in this case it is impossible to control the result.
4950
In the docstring generation mode, various popular templates are available in the settings that will guide the model output.
5051

52+
### Fill in the Middle Mode
53+
54+
55+
1. Create a new Python file or open an existing one.
56+
1. Type `def main():` or place the cursor where you'd like middle text to be generated.
57+
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.
58+
1. You can select the text then generate the related code.
59+
1. You may also right-click on "Generate Inline Code Completion In New Tab" to generate code in a new tab.
60+
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`.
61+
62+
You can customize the length of the generated code by adjusting `Max New Tokens` and `Min New Tokens` parameters in the extension settings.
63+
The number of generated tokens is also influenced by the `Server Request Timeout` setting.
64+
65+
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.
66+
67+
To enable fill in the middle mode, check the `Fill In The Middle Mode` checkbox in the extension settings.
68+
5169
### Monitoring Extension Output
5270

5371
To examine the input and output from the code generation API, follow these steps:

modules/openvino_code/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/openvino_code/package.json

+40-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"publisher": "OpenVINO",
33
"name": "openvino-code-completion",
4-
"version": "0.0.6",
4+
"version": "0.0.8",
55
"displayName": "OpenVINO Code Completion",
66
"description": "VSCode extension for AI code completion with OpenVINO",
77
"icon": "media/logo.png",
@@ -190,11 +190,12 @@
190190
"openvinoCode.model": {
191191
"order": 0,
192192
"type": "string",
193-
"default": "codet5p-220m-py",
193+
"default": "code-t5",
194194
"enum": [
195-
"codet5p-220m-py",
196-
"decicoder-1b-openvino-int8",
197-
"stablecode-completion-3b-int8"
195+
"code-t5",
196+
"decicoder-1b-openvino",
197+
"stablecode-completion",
198+
"deepseek-coder"
198199
],
199200
"description": "Which model to use for code generation."
200201
},
@@ -229,6 +230,40 @@
229230
"default": "false",
230231
"description": "When checked inline complention will be generated in streaming mode"
231232
},
233+
"openvinoCode.fillInTheMiddleMode": {
234+
"order": 4,
235+
"type": "boolean",
236+
"default": "false",
237+
"description":
238+
"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."
239+
},
240+
"openvinoCode.startToken": {
241+
"order": 7,
242+
"type": "string",
243+
"default": "< |fim_begin| >",
244+
"description":
245+
"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."
246+
},
247+
"openvinoCode.middleToken": {
248+
"order": 8,
249+
"type": "string",
250+
"default": "<|fim▁hole|>",
251+
"description":
252+
"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."
253+
},
254+
"openvinoCode.endToken": {
255+
"order": 9,
256+
"type": "string",
257+
"default": "<|fim▁end|>",
258+
"description":
259+
"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."
260+
},
261+
"openvinoCode.stopToken": {
262+
"order": 10,
263+
"type": "string",
264+
"default": "<|endoftext|>",
265+
"description": "(Optional) Stop token."
266+
},
232267
"openvinoCode.temperature": {
233268
"order": 4,
234269
"type": "number",
+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export enum Features {
22
CODE_COMPLETION = 'Code Completion',
33
SUMMARIZATION = 'Summarization',
4+
FIM = 'Fill-in-the-middle',
45
}

modules/openvino_code/shared/model.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,26 @@ enum ModelId {
44
CODE_T5_220M = 'Salesforce/codet5p-220m-py',
55
DECICODER_1B_OPENVINO_INT8 = 'chgk13/decicoder-1b-openvino-int8',
66
STABLECODE_COMPLETION_ALPHA_3B_4K_OPENVINO_INT8 = 'chgk13/stablecode-completion-alpha-3b-4k-openvino-int8',
7+
DEEPSEEK_CODER_1_3B = 'kumarijy/deepseek-coder-1_3b-instruct-openvino-int8',
78
}
89

910
export enum ModelName {
10-
CODE_T5_220M = 'codet5p-220m-py',
11-
DECICODER_1B_OPENVINO_INT8 = 'decicoder-1b-openvino-int8',
12-
STABLECODE_COMPLETION_ALPHA_3B_4K_OPENVINO_INT8 = 'stablecode-completion-3b-int8',
11+
CODE_T5_220M = 'code-t5',
12+
DECICODER_1B_OPENVINO_INT8 = 'decicoder-1b-openvino',
13+
STABLECODE_COMPLETION_ALPHA_3B_4K_OPENVINO_INT8 = 'stablecode-completion',
14+
DEEPSEEK_CODER_1_3B = 'deepseek-coder',
1315
}
1416

1517
export const MODEL_NAME_TO_ID_MAP: Record<ModelName, ModelId> = {
1618
[ModelName.CODE_T5_220M]: ModelId.CODE_T5_220M,
1719
[ModelName.DECICODER_1B_OPENVINO_INT8]: ModelId.DECICODER_1B_OPENVINO_INT8,
1820
[ModelName.STABLECODE_COMPLETION_ALPHA_3B_4K_OPENVINO_INT8]: ModelId.STABLECODE_COMPLETION_ALPHA_3B_4K_OPENVINO_INT8,
21+
[ModelName.DEEPSEEK_CODER_1_3B]: ModelId.DEEPSEEK_CODER_1_3B,
1922
};
2023

2124
export const MODEL_SUPPORTED_FEATURES: Record<ModelName, Features[]> = {
2225
[ModelName.CODE_T5_220M]: [Features.CODE_COMPLETION],
2326
[ModelName.DECICODER_1B_OPENVINO_INT8]: [Features.CODE_COMPLETION, Features.SUMMARIZATION],
2427
[ModelName.STABLECODE_COMPLETION_ALPHA_3B_4K_OPENVINO_INT8]: [Features.CODE_COMPLETION, Features.SUMMARIZATION],
28+
[ModelName.DEEPSEEK_CODER_1_3B]: [Features.CODE_COMPLETION, Features.SUMMARIZATION, Features.FIM],
2529
};

modules/openvino_code/side-panel-ui/src/components/sections/OverviewSection/OverviewSection.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ export function OverviewSection(): JSX.Element {
77
OpenVINO Code provides the following features:
88
<ul>
99
<li>Inline Code Completion</li>
10-
<li>Summarization via docstring</li>
10+
<li>Summarization via docstring</li>
11+
<li>Fill in the Middle Mode</li>
1112
</ul>
1213
To use OpenVINO Code please start the server.
1314
</span>

modules/openvino_code/side-panel-ui/src/components/sections/ServerSection/ModelSelect/ModelSelect.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const options: SelectOptionProps<ModelName>[] = [
77
{ value: ModelName.CODE_T5_220M },
88
{ value: ModelName.DECICODER_1B_OPENVINO_INT8 },
99
{ value: ModelName.STABLECODE_COMPLETION_ALPHA_3B_4K_OPENVINO_INT8 },
10+
{ value: ModelName.DEEPSEEK_CODER_1_3B },
1011
];
1112

1213
interface ModelSelectProps {
@@ -34,7 +35,7 @@ export const ModelSelect = ({
3435
disabled={disabled}
3536
onChange={(value) => onChange(value)}
3637
></Select>
37-
{isServerStopped && <span>Supported Featues: {supportedFeatures.join(', ')}</span>}
38+
{isServerStopped && <span>Supported Features: {supportedFeatures.join(', ')}</span>}
3839
</>
3940
);
4041
};

0 commit comments

Comments
 (0)