DEADLOCK007X commited on
Commit
37475c4
·
1 Parent(s): e62582d

Improve JSON extraction with fallback methods

Browse files
Files changed (1) hide show
  1. tinyllama_inference.py +8 -13
tinyllama_inference.py CHANGED
@@ -38,22 +38,17 @@ def extract_json(response_text):
38
 
39
  def evaluate_code(question, code):
40
  prompt = f"""You are an expert code evaluator.
41
- Evaluate the following solution for the given problem.
42
- Rate the solution as follows:
43
- - 5 stars: Perfect solution; it is correct, efficient, and follows best practices.
44
- - 4 stars: Correct solution with minor issues or improvements possible.
45
- - 3 stars: Partially correct solution with noticeable issues.
46
- - 2 stars: Incorrect solution with some correct elements.
47
- - 1 star: Mostly incorrect solution.
48
- - 0 stars: Completely incorrect solution.
49
- Respond with exactly one JSON object (with no extra text) that has exactly two keys:
50
- "stars": an integer between 0 and 5,
51
- "feedback": a concise string message explaining your rating.
52
- The JSON must start with '{{' and end with '}}'.
53
- Do not output any additional text.
54
  Question: "{question}"
55
  Solution: "{code}"
56
  Your response:"""
 
 
57
 
58
  tokenizer, model = load_model()
59
  inputs = tokenizer(prompt, return_tensors="pt")
 
38
 
39
  def evaluate_code(question, code):
40
  prompt = f"""You are an expert code evaluator.
41
+ For the following problem and solution, provide exactly one JSON object that contains your evaluation.
42
+ The JSON object must have exactly two keys:
43
+ "stars": an integer between 0 and 5, where 5 means a perfect solution and 0 means completely incorrect.
44
+ "feedback": a concise explanation of your rating.
45
+ Do not include any extra text, examples, or multiple responses.
46
+ Only evaluate the code provided below.
 
 
 
 
 
 
 
47
  Question: "{question}"
48
  Solution: "{code}"
49
  Your response:"""
50
+ # ... rest of the code remains unchanged ...
51
+
52
 
53
  tokenizer, model = load_model()
54
  inputs = tokenizer(prompt, return_tensors="pt")