8000 Added how to use commit0 for sampling during STAR training by wenting-zhao · Pull Request #105 · commit-0/commit0 · GitHub
[go: up one dir, main page]

Skip to content

Added how to use commit0 for sampling during STAR training #105

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

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixes formatting
  • Loading branch information
wenting-zhao committed Dec 23, 2024
commit 06daf7b48a828cb2d5e6713ebc407f4cc73523ad
2 changes: 1 addition & 1 deletion commit0/harness/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def extract_code_blocks(text: str) -> List[str]:
from the text.

"""
pattern = r"```python\n(.*?)```"
pattern = r'(?s)```(?:python|py)?(.*?)```'
matches = re.finditer(pattern, text, re.DOTALL)
return [match.group(1).strip() for match in matches]

Expand Down
8 changes: 4 additions & 4 deletions examples/star/inference.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List
from typing import Dict, List
from datasets import Dataset
from vllm import LLM, SamplingParams
from examples.star.utils import generate_prompt, cleanup
Expand Down Expand Up @@ -28,14 +28,14 @@ def generate_predictions(
sampling_params = SamplingParams(n=n, temperature=temperature, max_tokens=512)
llm = LLM(model=model_name)

prompts: List[str] = []
prompts: List[List[Dict]] = []
for example in dataset:
prompt = example["prompt"]
test = example["test"]
prompt = generate_prompt(prompt, test)
prompts.append(prompt)
prompts.append([{"role": "user", "content": prompt}])

outputs = llm.generate(prompts, sampling_params)
outputs = llm.chat(prompts, sampling_params)

results: List[List[str]] = []
for output in outputs:
Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ packages = ["commit0", "agent"]
agent = [
"import-deps>=0.3.0",
"PyMuPDF>=1.24.5",
"aider-chat",
#"aider-chat>=0.69.1",
]
example = [
"vllm",
"transformers",
"vllm==0.6.5",
"transformers>=4.47.1",
"setuptools",
"accelerate",
"wandb>=0.19.0",
"openai>=1.58.1",
]

[project.urls]
Expand Down
Loading
0