RichardErkhov commited on
Commit
8b4d829
1 Parent(s): ec31eff

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +73 -0
README.md ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Quantization made by Richard Erkhov.
2
+
3
+ [Github](https://github.com/RichardErkhov)
4
+
5
+ [Discord](https://discord.gg/pvy7H8DZMG)
6
+
7
+ [Request more models](https://github.com/RichardErkhov/quant_request)
8
+
9
+
10
+ mamba_790_hf_qa - bnb 8bits
11
+ - Model creator: https://huggingface.co/DeepMount00/
12
+ - Original model: https://huggingface.co/DeepMount00/mamba_790_hf_qa/
13
+
14
+
15
+
16
+
17
+ Original model description:
18
+ ---
19
+ language:
20
+ - it
21
+ license: apache-2.0
22
+ datasets:
23
+ - DeepMount00/gquad_it
24
+ pipeline_tag: question-answering
25
+ ---
26
+
27
+ ## SQuAD-it Evaluation
28
+
29
+ The Stanford Question Answering Dataset (SQuAD) in Italian (SQuAD-it) is used to evaluate the model's reading comprehension and question-answering capabilities. The following table presents the F1 score and Exact Match (EM) metrics:
30
+
31
+ | Model | F1 Score | Exact Match (EM) |
32
+ |----------------------------------------------|----------|------------------|
33
+ | **DeepMount00/Gemma_QA_ITA_v3** | **77.24%** | **64.60%** |
34
+ | **DeepMount00/Gemma_QA_ITA_v2** | **77.17%** | **63.82%** |
35
+ | **DeepMount00/mamba_790_hf_qa** | **75.89%** | **66.71%** |
36
+ | **DeepMount00/Gemma_QA_ITA** | **59.59%** | **40.68%** |
37
+
38
+ ## How to Use
39
+ How to use mamba q&a
40
+
41
+ ```python
42
+ from transformers import MambaConfig, MambaForCausalLM, AutoTokenizer
43
+ import torch
44
+
45
+ model_name = "DeepMount00/mamba_790_hf_qa"
46
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
47
+ model = MambaForCausalLM.from_pretrained(model_name, device_map={"": 0}).eval()
48
+
49
+
50
+ def predict(contesto, domanda):
51
+ device = "cuda:0"
52
+ prefix_text = 'Di seguito ti verrà fornito un contesto e poi una domanda. il tuo compito è quello di rispondere alla domanda basandoti esclusivamente sul contesto\n\n'
53
+
54
+ prompt = f"""{prefix_text}##CONTESTO: {contesto}\n##DOMANDA: {domanda}\n"""
55
+
56
+ input_ids = tokenizer([prompt], return_tensors="pt").to(device)
57
+
58
+ generate_ids = model.generate(**input_ids, max_new_tokens=150, eos_token_id=8112)
59
+
60
+ answer = tokenizer.batch_decode(generate_ids)
61
+ try:
62
+ final_answer = answer[0].split("##RISPOSTA: ")[1].split("##END")[0].strip("\n")
63
+ except IndexError:
64
+ final_answer = ""
65
+ return final_answer
66
+
67
+
68
+ contesto = """La torre degli Asinelli è una delle cosiddette due torri di Bologna, simbolo della città, situate in piazza di porta Ravegnana, all'incrocio tra le antiche strade San Donato (ora via Zamboni), San Vitale, Maggiore e Castiglione. Eretta, secondo la tradizione, fra il 1109 e il 1119 dal nobile Gherardo Asinelli, la torre è alta 97,20 metri, pende verso ovest per 2,23 metri e presenta all'interno una scalinata composta da 498 gradini. Ancora non si può dire con certezza quando e da chi fu costruita la torre degli Asinelli. Si presume che la torre debba il proprio nome a Gherardo Asinelli, il nobile cavaliere di fazione ghibellina al quale se ne attribuisce la costruzione, iniziata secondo una consolidata tradizione l'11 ottobre 1109 e terminata dieci anni dopo, nel 1119."""
69
+ domanda = "Dove si trova precisamente la torre degli Asinelli?"
70
+
71
+ print(predict(contesto, domanda))
72
+ ```
73
+