Pedram Rostami commited on
Commit
390be8d
·
1 Parent(s): 73836fc

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +92 -0
README.md ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc
3
+ language:
4
+ - fa
5
+ - en
6
+ library_name: transformers
7
+ tags:
8
+ - text-generation-inference
9
+ inference: false
10
+ widget:
11
+ - text: PersianMind is a Persian LLM.
12
+ output:
13
+ url: PersianMind.jpg
14
+ metrics:
15
+ - bleu
16
+ - comet
17
+ - accuracy
18
+ - perplexity
19
+ - spearmanr
20
+ pipeline_tag: text-generation
21
+ ---
22
+
23
+
24
+ <Gallery />
25
+
26
+ # PersianMind
27
+
28
+ PersianMind is a a cross-lingual Persian-English large language model.
29
+
30
+ ### Model Description
31
+
32
+ - **Developed by:** [Pedram Rostami](mailto:pedram.rostami@ut.ac.ir), [Ali Salemi](mailto:alisalemi@ut.ac.ir), and [Mohammad Javad Dousti](mailto:mjdousti@ut.ac.ir)
33
+ - **Model type:** Language model
34
+ - **Languages:** English and Persian
35
+ - **License:** [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)
36
+
37
+ ## How to Get Started with the Model
38
+
39
+ Use the code below to get started with the model. Note that you need to install `sentencepiece` and `accelerate` libraries to run this code.
40
+
41
+ ```python
42
+ from transformers import LlamaTokenizer, LlamaForCausalLM
43
+ import torch
44
+
45
+ device = "cuda" if torch.cuda.is_available() else "cpu"
46
+ model = LlamaForCausalLM.from_pretrained(
47
+ "universitytehran/PersianMind-v1.0",
48
+ torch_dtype=torch.bfloat16,
49
+ low_cpu_mem_usage=True,
50
+ device_map={"": device},
51
+ )
52
+ tokenizer = LlamaTokenizer.from_pretrained(
53
+ "universitytehran/PersianMind-v1.0",
54
+ )
55
+
56
+ TEMPLATE = "{context}\nYou: {prompt}\nPersianMind: "
57
+ CONTEXT = "This is a conversation with PersianMind. It is an artificial intelligence model designed by a team of " \
58
+ "NLP experts at the University of Tehran to help you with various tasks such as answering questions, " \
59
+ "providing recommendations, and helping with decision making. You can ask it anything you want and " \
60
+ "it will do its best to give you accurate and relevant information."
61
+ PROMPT = "در مورد هوش مصنوعی توضیح بده."
62
+
63
+ model_input = TEMPLATE.format(context=CONTEXT, prompt=PROMPT)
64
+ input_tokens = tokenizer(model_input, return_tensors="pt")
65
+ input_tokens = input_tokens.to(device)
66
+ generate_ids = model.generate(**input_tokens, max_new_tokens=512, do_sample=False, repetition_penalty=1.1)
67
+ model_output = tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
68
+ model_output = model_output.replace(model_input, "")
69
+
70
+ print(model_output)
71
+ ```
72
+
73
+ ## License
74
+ PersianMind is subject to Meta's ([LLaMa2 Community License Agreement](https://raw.githubusercontent.com/facebookresearch/llama/main/LICENSE).
75
+ It is further licensed under [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/) which allows non-commercial use of the model.
76
+ Commercial use of this model requires written agreement which must be obtained from the copyright holders which are listed as developers in this page.
77
+ If you suspect any violations, please reach out to us.
78
+
79
+
80
+ ## Citation
81
+
82
+ If you find the following model helpful, please ensure to cite the following paper.
83
+
84
+ **BibTeX:**
85
+ ```bibtex
86
+ @article{persianmind,
87
+ title={{PersianMind: A Cross-Lingual Persian-English Large Language Model}},
88
+ author={Rostami, Pedram and Salemi, Ali and Dousti, Mohammad Javad},
89
+ journal={arXiv preprint},
90
+ year={2024}
91
+ }
92
+ ```