-
Notifications
You must be signed in to change notification settings - Fork 74
Add tool completion to batch inference #461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7d019d5
test
yunfeng-scale 35f4957
Impl
yunfeng-scale 43aa1d6
remove logging
yunfeng-scale f20ce4d
lints
yunfeng-scale 32ad5ca
fix tests
yunfeng-scale 20f54f0
Merge remote-tracking branch 'origin/main' into yunfeng-tool-completion
yunfeng-scale c07a6f6
fix
yunfeng-scale 96e0c66
fix
yunfeng-scale a0851a5
try fix unit test
yunfeng-scale 5bda0e8
fix
yunfeng-scale aec60ce
no cover
yunfeng-scale b158dbe
stop sequences
yunfeng-scale ab59e1a
erge branch 'yunfeng-tool-completion' of https://github.com/scaleapi/…
yunfeng-scale 07ccb41
Merge remote-tracking branch 'origin/main' into yunfeng-tool-completion
yunfeng-scale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
model-engine/model_engine_server/inference/batch_inference/generate_tool_sample_data.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import json | ||
|
|
||
| COMPLETION_PROMPT1 = """\ | ||
| FYI: you can write code like this: | ||
| ```python | ||
| import math | ||
| print(math.sqrt(2)) | ||
| ``` | ||
| 1.41... | ||
| >>> | ||
|
|
||
| For reference, the third digit of 4.32 is 2. Also, use "Final Answer: X" to indicate your final answer. | ||
|
|
||
| ### Problem: | ||
|
|
||
| What is the 4th digit of pi? | ||
|
|
||
| ### Answer: | ||
| ```python | ||
| import math | ||
| print(math.pi) | ||
| ``` | ||
| 3.141592653589793 | ||
| >>> | ||
|
|
||
| Final Answer: 1 | ||
|
|
||
| ### Problem: | ||
|
|
||
| What is the 4th digit of the square root of 2? | ||
|
|
||
| ### Answer: | ||
| """ | ||
|
|
||
| COMPLETION_PROMPT2 = """\ | ||
| FYI: you can write code like this: | ||
| ```python | ||
| import math | ||
| print(math.sqrt(2)) | ||
| ``` | ||
| 1.41... | ||
| >>> | ||
|
|
||
| For reference, the third digit of 4.32 is 2. Also, use "Final Answer: X" to indicate your final answer. | ||
|
|
||
| ### Problem: | ||
|
|
||
| What is the 4th digit of pi? | ||
|
|
||
| ### Answer: | ||
| ```python | ||
| import math | ||
| print(math.pi) | ||
| ``` | ||
| 3.141592653589793 | ||
| >>> | ||
|
|
||
| Final Answer: 1 | ||
|
|
||
| ### Problem: | ||
|
|
||
| What is the 5th digit of the square root of 2? | ||
|
|
||
| ### Answer: | ||
| """ | ||
|
|
||
| data = { | ||
| "prompts": [ | ||
| COMPLETION_PROMPT1, | ||
| COMPLETION_PROMPT2, | ||
| "what is deep learning", | ||
| ], | ||
| "max_new_tokens": 100, | ||
| "temperature": 0.0, | ||
| "return_token_log_probs": True, | ||
| "stop_sequences": ["</s>", "\n### Problem:\n", ">>>\n"], | ||
| } | ||
|
|
||
| json.dump(data, open("sample_data_tool.json", "w")) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
model-engine/model_engine_server/inference/batch_inference/sample_config_tool.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "input_data_path":"./sample_data_tool.json", | ||
| "output_data_path":"./sample_output_tool.json", | ||
| "model_config":{ | ||
| "model":"mistral-7b", | ||
| "checkpoint_path":"s3://scale-ml/models/mistral-7b", | ||
| "num_shards": 1, | ||
| "labels": {"team": "my_team"} | ||
| }, | ||
| "data_parallelism":2, | ||
| "tool_config": { | ||
| "name": "code_evaluator" | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
model-engine/model_engine_server/inference/batch_inference/sample_data_tool.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "prompts": [ | ||
| "FYI: you can write code like this: \n```python\nimport math\nprint(math.sqrt(2))\n```\n1.41...\n>>>\n\nFor reference, the third digit of 4.32 is 2. Also, use \"Final Answer: X\" to indicate your final answer.\n\n### Problem:\n\nWhat is the 4th digit of pi?\n\n### Answer:\n```python\nimport math\nprint(math.pi)\n```\n3.141592653589793\n>>>\n\nFinal Answer: 1\n\n### Problem:\n\nWhat is the 4th digit of the square root of 2?\n\n### Answer: \n", | ||
| "FYI: you can write code like this: \n```python\nimport math\nprint(math.sqrt(2))\n```\n1.41...\n>>>\n\nFor reference, the third digit of 4.32 is 2. Also, use \"Final Answer: X\" to indicate your final answer.\n\n### Problem:\n\nWhat is the 4th digit of pi?\n\n### Answer:\n```python\nimport math\nprint(math.pi)\n```\n3.141592653589793\n>>>\n\nFinal Answer: 1\n\n### Problem:\n\nWhat is the 5th digit of the square root of 2?\n\n### Answer: \n", | ||
| "what is deep learning" | ||
| ], | ||
| "max_new_tokens": 100, | ||
| "temperature": 0.0, | ||
| "return_token_log_probs": true, | ||
| "stop_sequences": [ | ||
| "</s>", | ||
| "\n### Problem:\n", | ||
| ">>>\n" | ||
| ] | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.