Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
bdceb68
Merge pull request #57 from deepseek-ai/bingxuan/dev
Nov 28, 2023
b71adab
Update README.md
guoday Nov 29, 2023
e690191
Update README.md
BingxuanWang Nov 30, 2023
24add12
Update README.md
Dec 5, 2023
9227359
Update README.md
foldl Dec 6, 2023
791c8e2
Update README.md
Dec 6, 2023
a1874c8
Update run.py
guoday Dec 28, 2023
3963f91
Update README.md
guoday Dec 28, 2023
b564a69
Add files via upload
guoday Dec 28, 2023
2a4842b
Add files via upload
guoday Dec 28, 2023
8c3def1
Delete pictures/Math.png
guoday Dec 28, 2023
81c0852
Add files via upload
guoday Dec 28, 2023
d3bb741
Update README.md
pkuzqh Jan 5, 2024
c160d96
fix add_generation_prompt in latest version
DejianYang Jan 9, 2024
6590983
Fix the position of add_generation_prompt
pcystc Jan 10, 2024
bda040a
Merge pull request #93 from pcystc/main
guoday Jan 10, 2024
e863eb6
Merge pull request #70 from foldl/foldl-patch-1
guoday Jan 10, 2024
94a36b7
Update README.md
Jan 26, 2024
ab5d1b2
add leetcode evaluation
DejianYang Jan 26, 2024
d1898bc
update model name
DejianYang Jan 26, 2024
e7841b5
Merge pull request #105 from deepseek-ai/ydj/leetcode
DejianYang Jan 26, 2024
f848715
Update README.md
eltociear Jan 28, 2024
9d2c23c
Merge pull request #109 from eltociear/patch-1
DejianYang Jan 29, 2024
5ca49c9
Update eos token id
guoday Feb 2, 2024
ba9525b
Update app.py
guoday Feb 2, 2024
b22ca95
Update README.md
Feb 2, 2024
c1bb6d1
Update README.md
pkuzqh Feb 4, 2024
23931be
Update README.md
guoday Feb 6, 2024
cfa072c
fix in-page link for detailed eval results
JacobLinCool Feb 17, 2024
e348ac8
Merge pull request #120 from JacobLinCool/patch-1
guoday Feb 18, 2024
1471702
Update app.py
pkuzqh Feb 28, 2024
74809ce
Complete missing `import`
AntiQuality Mar 7, 2024
fd2db2c
Merge pull request #135 from AntiQuality/patch-1
guoday Mar 12, 2024
42aedab
set transformers version to 4.35 to avoid a lot of issues
DejianYang Apr 9, 2024
7df235b
Update requirements.txt
DejianYang Apr 9, 2024
b7ba565
Update requirements.txt for finetune
DejianYang Apr 16, 2024
02dc851
Update README.md
DillionApple Nov 11, 2025
2f9fd85
Merge pull request #673 from DillionApple/patch-1
pkuzqh Nov 11, 2025
5018f86
Add GitHub Actions workflow for Python package using Conda
18488292860-coder Apr 24, 2026
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
34 changes: 34 additions & 0 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Python Package using Conda

on: [push]

jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
max-parallel: 5

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Install dependencies
run: |
conda env update --file environment.yml --name base
- name: Lint with flake8
run: |
conda install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
conda install pytest
pytest
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
__pycache__/
Evaluation/MBPP/eval_instruct.sh
Evaluation/MBPP/eval_instruct.sh
Evaluation/LeetCode/output/
3 changes: 2 additions & 1 deletion Evaluation/HumanEval/eval_instruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def generate_one(example, lang, tokenizer, model):
prompt = build_deepseekcoder_instruction(languge_settings[lang]['full_name'], example['prompt'])
inputs = tokenizer.apply_chat_template(
[{'role': 'user', 'content': prompt }],
return_tensors="pt"
return_tensors="pt",
add_generation_prompt=True
).to(model.device)

stop_id = tokenizer.convert_tokens_to_ids("<|EOT|>")
Expand Down
180 changes: 180 additions & 0 deletions Evaluation/LeetCode/data/20240121-Jul-zh.jsonl

Large diffs are not rendered by default.

180 changes: 180 additions & 0 deletions Evaluation/LeetCode/data/20240121-Jul.jsonl

Large diffs are not rendered by default.

86 changes: 86 additions & 0 deletions Evaluation/LeetCode/evaluate_leetcode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import re
import json
from pathlib import Path
from collections import defaultdict
from human_eval.evaluation import evaluate_functional_correctness

version = "20240121-Jul"

DATA_DIR = Path(__file__).parent / "data"

def extract_python_code(generation: str):
generation = generation.replace("[PYTHON]", '```python').replace("[/PYTHON]", '```')
if '```python' in generation:
p_code = re.compile(r'```python\n(.*?)\n```', flags=re.DOTALL)
code_block = p_code.findall(generation)[0]
return code_block
else:
codelist = re.split("\ndef|\nclass|\nif|\n#|\nprint", generation)
return codelist[0]

def evaluate_main(generation_path: str, result_path: str, temp_dir: str):
problem_path = (DATA_DIR / f"{version}.jsonl").as_posix()

print(problem_path)
problems = [json.loads(line) for line in open(problem_path, 'r')]

id2problems = { x['task_id']: x for x in problems }

results = [json.loads(line) for line in open(generation_path, 'r')]
for result in results:
if 'task_id' not in result:
result['task_id'] = problems[result['index']]['task_id']

if 'generation' not in result:
try:
if 'output' not in result:
result['output'] = result['response']
if result['output'].startswith("\n "):
func_code = extract_python_code(result['prompt_sft']).strip()
result['generation'] = func_code + '\n' + result['output']
else:
result['generation'] = extract_python_code(result['output'])
except:
result['generation'] = result['output']

with open(result_path, 'w') as fr:
for result in results:
fr.write(json.dumps(result) + "\n")

score = evaluate_functional_correctness(
input_file=result_path,
tmp_dir=temp_dir,
problem_file=problem_path,
result_path=result_path
)

hardness_results = defaultdict(int)
for result in [json.loads(line) for line in open(result_path, 'r')]:
problem = id2problems[result['task_id']]

hardness = problem['meta']['difficulty']
hardness_results[hardness] += 1
hardness_results[hardness + "_correct"] += result['passed']

print("="*100)
print("Evaluate {} over.".format(generation_path))
print("Pass@1: {:.3f}".format(score["pass@1"]))
for key in ["Easy", "Medium", "Hard"]:
if key.endswith("_correct"):
continue
acc = hardness_results[key+"_correct"] / hardness_results[key]
print("{}: {:.3f}({}/{})".format(key, acc, hardness_results[key+"_correct"], hardness_results[key]))

if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--generation_path", type=str, required=True)
parser.add_argument("--result_path", type=str)
parser.add_argument("--temp_dir", type=str, default="output/temp")
args = parser.parse_args()

if args.result_path is None:
args.result_path = args.generation_path.replace(".jsonl", "_result.jsonl")

evaluate_main(args.generation_path, args.result_path, temp_dir=args.temp_dir)
pass
Empty file.
49 changes: 49 additions & 0 deletions Evaluation/LeetCode/human_eval/data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from typing import Iterable, Dict
import gzip
import json
import os


ROOT = os.path.dirname(os.path.abspath(__file__))
HUMAN_EVAL = os.path.join(ROOT, "..", "data", "HumanEval.jsonl.gz")


def read_problems(evalset_file: str = HUMAN_EVAL) -> Dict[str, Dict]:
return {task["task_id"]: task for task in stream_jsonl(evalset_file)}


def stream_jsonl(filename: str) -> Iterable[Dict]:
"""
Parses each jsonl line and yields it as a dictionary
"""
if filename.endswith(".gz"):
with open(filename, "rb") as gzfp:
with gzip.open(gzfp, 'rt') as fp:
for line in fp:
if any(not x.isspace() for x in line):
yield json.loads(line)
else:
with open(filename, "r") as fp:
for line in fp:
if any(not x.isspace() for x in line):
yield json.loads(line)


def write_jsonl(filename: str, data: Iterable[Dict], append: bool = False):
"""
Writes an iterable of dictionaries to jsonl
"""
if append:
mode = 'ab'
else:
mode = 'wb'
filename = os.path.expanduser(filename)
if filename.endswith(".gz"):
with open(filename, mode) as fp:
with gzip.GzipFile(fileobj=fp, mode='wb') as gzfp:
for x in data:
gzfp.write((json.dumps(x) + "\n").encode('utf-8'))
else:
with open(filename, mode) as fp:
for x in data:
fp.write((json.dumps(x) + "\n").encode('utf-8'))
Loading