Spaces:
Configuration error

yonkasoft commited on
Commit
8225082
·
verified ·
1 Parent(s): 15f3506

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -14
app.py CHANGED
@@ -8,27 +8,22 @@ from torch.nn.functional import softmax
8
 
9
  app = Flask(__name__)
10
 
11
- # MongoDB bağlantısı
12
  mongo_client = pymongo.MongoClient('mongodb://localhost:27017/')
13
  db = mongo_client['EgitimDatabase']
14
  collection = db['test']
15
 
16
- # Model ve tokenizer'ı yükleme
17
- model_name = "alan-turing-institute/mt5-large-finetuned-mnli-xtreme-xnli"
18
- tokenizer = MT5Tokenizer.from_pretrained(model_name)
19
- model = MT5ForConditionalGeneration.from_pretrained(model_name)
20
- model.eval()
21
 
22
- def process_nli(premise: str, hypothesis: str):
23
- """NLI formatına uygun hale getirir"""
24
- return "".join(['xnli: premise: ', premise, ' hypothesis: ', hypothesis])
25
 
26
- def generate_text(title, keywords, subheadings):
27
- # Prompt oluşturma
28
- prompt = f"Başlık: {title}\nAnahtar Kelimeler: {keywords}\nAlt Başlıklar: {subheadings}\n\nBu bilgilerle bir metin oluşturun:"
29
- inputs = tokenizer(prompt, return_tensors="pt")
 
30
 
31
- # Modelden çıktı alma
 
 
32
  outputs = model.generate(**inputs, output_scores=True, return_dict_in_generate=True, num_beams=5)
33
  generated_text = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)
34
 
 
8
 
9
  app = Flask(__name__)
10
 
11
+ #hazırladığım verilere ait database
12
  mongo_client = pymongo.MongoClient('mongodb://localhost:27017/')
13
  db = mongo_client['EgitimDatabase']
14
  collection = db['test']
15
 
 
 
 
 
 
16
 
 
 
 
17
 
18
+ #kullanıcılara ait inputların kaydedileceği database
19
+ mongo_client = pymongo.MongoClient('mongodb://localhost:27017/')
20
+ db = mongo_client['EgitimDatabase']
21
+ collection = db['input']
22
+
23
 
24
+
25
+
26
+
27
  outputs = model.generate(**inputs, output_scores=True, return_dict_in_generate=True, num_beams=5)
28
  generated_text = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)
29