ramalMr commited on
Commit
b4637e1
·
verified ·
1 Parent(s): e798af8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -31,6 +31,7 @@ def generate(file, temperature, max_new_tokens, top_p, repetition_penalty):
31
  sentences = text.split('.')
32
  random.shuffle(sentences) # Shuffle sentences
33
 
 
34
  with tempfile.NamedTemporaryFile(mode='w', newline='', delete=False, suffix='.csv') as tmp:
35
  fieldnames = ['Original Sentence', 'Generated Sentence']
36
  writer = csv.DictWriter(tmp, fieldnames=fieldnames)
@@ -48,6 +49,7 @@ def generate(file, temperature, max_new_tokens, top_p, repetition_penalty):
48
  "repetition_penalty": repetition_penalty,
49
  "do_sample": True,
50
  "seed": 42,
 
51
  }
52
 
53
  try:
@@ -56,9 +58,11 @@ def generate(file, temperature, max_new_tokens, top_p, repetition_penalty):
56
  for response in stream:
57
  output += response.token.text
58
 
 
59
  generated_sentences = re.split(r'(?<=[\.\!\?:])[\s\n]+', output)
60
  generated_sentences = [s.strip() for s in generated_sentences if s.strip() and s != '.']
61
 
 
62
  for generated_sentence in generated_sentences:
63
  writer.writerow({'Original Sentence': sentence, 'Generated Sentence': generated_sentence})
64
 
 
31
  sentences = text.split('.')
32
  random.shuffle(sentences) # Shuffle sentences
33
 
34
+
35
  with tempfile.NamedTemporaryFile(mode='w', newline='', delete=False, suffix='.csv') as tmp:
36
  fieldnames = ['Original Sentence', 'Generated Sentence']
37
  writer = csv.DictWriter(tmp, fieldnames=fieldnames)
 
49
  "repetition_penalty": repetition_penalty,
50
  "do_sample": True,
51
  "seed": 42,
52
+ "use_cache": False
53
  }
54
 
55
  try:
 
58
  for response in stream:
59
  output += response.token.text
60
 
61
+ # Modelden gelen yanıtı cümlelere ayır
62
  generated_sentences = re.split(r'(?<=[\.\!\?:])[\s\n]+', output)
63
  generated_sentences = [s.strip() for s in generated_sentences if s.strip() and s != '.']
64
 
65
+ # Her cümleyi ayrı bir satır olarak CSV'ye yaz
66
  for generated_sentence in generated_sentences:
67
  writer.writerow({'Original Sentence': sentence, 'Generated Sentence': generated_sentence})
68