ramalMr commited on
Commit
231908c
·
verified ·
1 Parent(s): f5a3917

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -30,19 +30,27 @@ def generate(file, prompt, temperature, max_new_tokens, top_p, repetition_penalt
30
  "seed": 42,
31
  }
32
 
 
33
  for sentence in sentences:
34
  try:
35
  stream = client.text_generation(f"{prompt} Output the response in the following JSON format: {{'generated_sentence': 'The generated sentence text', 'confidence_score': 0.9}} {sentence}", **generate_kwargs, stream=True, details=True, return_full_text=False)
36
  output = ""
37
  for response in stream:
38
  output += response.token.text
 
39
  data.append({"original_sentence": sentence, "generated_data": output})
40
  except Exception as e:
41
  print(f"Error generating data for sentence '{sentence}': {e}")
 
 
42
 
43
  filename = "synthetic_data.json"
44
  save_to_json(data, filename)
45
 
 
 
 
 
46
  return filename
47
 
48
  def save_to_json(data, filename):
 
30
  "seed": 42,
31
  }
32
 
33
+ all_outputs = []
34
  for sentence in sentences:
35
  try:
36
  stream = client.text_generation(f"{prompt} Output the response in the following JSON format: {{'generated_sentence': 'The generated sentence text', 'confidence_score': 0.9}} {sentence}", **generate_kwargs, stream=True, details=True, return_full_text=False)
37
  output = ""
38
  for response in stream:
39
  output += response.token.text
40
+ all_outputs.append(output)
41
  data.append({"original_sentence": sentence, "generated_data": output})
42
  except Exception as e:
43
  print(f"Error generating data for sentence '{sentence}': {e}")
44
+ all_outputs.append("")
45
+ data.append({"original_sentence": sentence, "generated_data": ""})
46
 
47
  filename = "synthetic_data.json"
48
  save_to_json(data, filename)
49
 
50
+ with open("model_outputs.txt", "w", encoding="utf-8") as f:
51
+ for output in all_outputs:
52
+ f.write(output + "\n")
53
+
54
  return filename
55
 
56
  def save_to_json(data, filename):