Cicciokr commited on
Commit
cfc942c
·
verified ·
1 Parent(s): ad7b7bc

Removing of gpt2

Browse files
Files changed (1) hide show
  1. app.py +1 -11
app.py CHANGED
@@ -16,26 +16,16 @@ input_text = st.text_input("Testo:", value="Lorem ipsum dolor sit amet, [MASK] a
16
  #modelname = "./models/latin_bert/"
17
  #modelname = "LuisAVasquez/simple-latin-bert-uncased"
18
  modelname = "./models/bert-base-latin-uncased"
19
- # Model based on GPT 2
20
- modelname_gpt = "itserr/scratch_2-nodes_tokenizer_latbert-original_packing_fcocchi"
21
 
22
  tokenizer = AutoTokenizer.from_pretrained(modelname)
23
  model = AutoModelForMaskedLM.from_pretrained(modelname)
24
  fill_mask = pipeline("fill-mask", model=model, tokenizer=tokenizer)
25
 
26
- #Use GPT 2 to compare with BERT
27
- tokenizer_gpt = AutoTokenizer.from_pretrained(modelname_gpt)
28
- model_gpt = AutoModelForMaskedLM.from_pretrained(modelname_gpt)
29
- fill_mask_gpt = pipeline("fill-mask", model=model_gpt, tokenizer=tokenizer_gpt)
30
-
31
  if input_text:
32
  predictions = fill_mask(input_text)
33
  st.subheader("Risultati delle previsioni con Simple Latin Bert:")
34
  for pred in predictions:
35
  st.write(f"**Parola**: {pred['token_str']}, **Probabilità**: {pred['score']:.4f}, **Sequence**: {pred['sequence']}")
36
- predictions_gpt = fill_mask_gpt(input_text)
37
- st.subheader("Risultati delle previsioni con Simple Latin GPT2:")
38
- for pred_gpt in predictions_gpt:
39
- st.write(f"**Parola**: {pred_gpt['token_str']}, **Probabilità**: {pred_gpt['score']:.4f}, **Sequence**: {pred_gpt['sequence']}")
40
 
41
 
 
16
  #modelname = "./models/latin_bert/"
17
  #modelname = "LuisAVasquez/simple-latin-bert-uncased"
18
  modelname = "./models/bert-base-latin-uncased"
19
+
 
20
 
21
  tokenizer = AutoTokenizer.from_pretrained(modelname)
22
  model = AutoModelForMaskedLM.from_pretrained(modelname)
23
  fill_mask = pipeline("fill-mask", model=model, tokenizer=tokenizer)
24
 
 
 
 
 
 
25
  if input_text:
26
  predictions = fill_mask(input_text)
27
  st.subheader("Risultati delle previsioni con Simple Latin Bert:")
28
  for pred in predictions:
29
  st.write(f"**Parola**: {pred['token_str']}, **Probabilità**: {pred['score']:.4f}, **Sequence**: {pred['sequence']}")
 
 
 
 
30
 
31