Commit
•
f94d74e
1
Parent(s):
69083e6
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,121 @@
|
|
1 |
---
|
|
|
|
|
|
|
|
|
2 |
license: apache-2.0
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- tr
|
4 |
+
- en
|
5 |
+
pipeline_tag: text-generation
|
6 |
license: apache-2.0
|
7 |
+
base_model: Trendyol/Trendyol-LLM-7b-base-v1.1
|
8 |
---
|
9 |
+
|
10 |
+
# **Trendyol LLM v1.8**
|
11 |
+
Trendyol LLM v1.8 is a generative model that is based on Mistral 7B model. This is the repository for the chat model.
|
12 |
+
|
13 |
+
## Model Details
|
14 |
+
|
15 |
+
**Model Developers** Trendyol
|
16 |
+
|
17 |
+
**Input** Models input text only.
|
18 |
+
|
19 |
+
**Output** Models generate text only.
|
20 |
+
|
21 |
+
**Model Architecture** Trendyol LLM is an auto-regressive language model (based on Mistral 7b) that uses an optimized transformer architecture. The chat version is fine-tuned on instruction sets with the following trainables by using LoRA:
|
22 |
+
|
23 |
+
- **lr**=1e-4
|
24 |
+
- **lora_rank**=64
|
25 |
+
- **lora_alpha**=128
|
26 |
+
- **lora_trainable**=q_proj,v_proj,k_proj,o_proj,gate_proj,down_proj,up_proj
|
27 |
+
- **modules_to_save**=embed_tokens,lm_head
|
28 |
+
- **lora_dropout**=0.05
|
29 |
+
- **bf16**=True
|
30 |
+
- **max_seq_length**=1024
|
31 |
+
|
32 |
+
<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/peft/lora_diagram.png"
|
33 |
+
alt="drawing" width="600"/>
|
34 |
+
|
35 |
+
## Usage
|
36 |
+
|
37 |
+
```python
|
38 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
39 |
+
|
40 |
+
model_id = "Trendyol/Trendyol-LLM-7b-chat-v1.8"
|
41 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
42 |
+
model = AutoModelForCausalLM.from_pretrained(model_id,
|
43 |
+
device_map='auto',
|
44 |
+
load_in_8bit=True)
|
45 |
+
|
46 |
+
sampling_params = dict(do_sample=True, temperature=0.3, top_k=50, top_p=0.9)
|
47 |
+
|
48 |
+
pipe = pipeline("text-generation",
|
49 |
+
model=model,
|
50 |
+
tokenizer=tokenizer,
|
51 |
+
device_map="auto",
|
52 |
+
max_new_tokens=1024,
|
53 |
+
return_full_text=True,
|
54 |
+
repetition_penalty=1.1
|
55 |
+
)
|
56 |
+
|
57 |
+
DEFAULT_SYSTEM_PROMPT = "Sen yardımcı bir asistansın ve sana verilen talimatlar doğrultusunda en iyi cevabı üretmeye çalışacaksın.\n"
|
58 |
+
|
59 |
+
TEMPLATE = (
|
60 |
+
"[INST] {system_prompt}\n\n"
|
61 |
+
"{instruction} [/INST]"
|
62 |
+
)
|
63 |
+
|
64 |
+
def generate_prompt(instruction, system_prompt=DEFAULT_SYSTEM_PROMPT):
|
65 |
+
return TEMPLATE.format_map({'instruction': instruction,'system_prompt': system_prompt})
|
66 |
+
|
67 |
+
def generate_output(user_query, sys_prompt=DEFAULT_SYSTEM_PROMPT):
|
68 |
+
prompt = generate_prompt(user_query, sys_prompt)
|
69 |
+
outputs = pipe(prompt,
|
70 |
+
**sampling_params
|
71 |
+
)
|
72 |
+
return outputs[0]["generated_text"].split("[/INST]")[-1]
|
73 |
+
|
74 |
+
user_query = "Türkiye'de kaç il var?"
|
75 |
+
response = generate_output(user_query)
|
76 |
+
print(response)
|
77 |
+
```
|
78 |
+
|
79 |
+
with chat template:
|
80 |
+
```python
|
81 |
+
pipe = pipeline("conversational",
|
82 |
+
model=model,
|
83 |
+
tokenizer=tokenizer,
|
84 |
+
device_map="auto",
|
85 |
+
max_new_tokens=1024,
|
86 |
+
repetition_penalty=1.1
|
87 |
+
)
|
88 |
+
|
89 |
+
messages = [
|
90 |
+
{"role": "user", "content": "Türkiye'de kaç il var?"}
|
91 |
+
]
|
92 |
+
|
93 |
+
outputs = pipe(messages, **sampling_params)
|
94 |
+
print(outputs)
|
95 |
+
```
|
96 |
+
|
97 |
+
## Limitations, Risks, Bias, and Ethical Considerations
|
98 |
+
|
99 |
+
### Limitations and Known Biases
|
100 |
+
|
101 |
+
- **Primary Function and Application:** Trendyol LLM, an autoregressive language model, is primarily designed to predict the next token in a text string. While often used for various applications, it is important to note that it has not undergone extensive real-world application testing. Its effectiveness and reliability across diverse scenarios remain largely unverified.
|
102 |
+
|
103 |
+
- **Language Comprehension and Generation:** The model is primarily trained in standard English and Turkish. Its performance in understanding and generating slang, informal language, or other languages may be limited, leading to potential errors or misinterpretations.
|
104 |
+
|
105 |
+
- **Generation of False Information:** Users should be aware that Trendyol LLM may produce inaccurate or misleading information. Outputs should be considered as starting points or suggestions rather than definitive answers.
|
106 |
+
|
107 |
+
### Risks and Ethical Considerations
|
108 |
+
|
109 |
+
- **Potential for Harmful Use:** There is a risk that Trendyol LLM could be used to generate offensive or harmful language. We strongly discourage its use for any such purposes and emphasize the need for application-specific safety and fairness evaluations before deployment.
|
110 |
+
|
111 |
+
- **Unintended Content and Bias:** The model was trained on a large corpus of text data, which was not explicitly checked for offensive content or existing biases. Consequently, it may inadvertently produce content that reflects these biases or inaccuracies.
|
112 |
+
|
113 |
+
- **Toxicity:** Despite efforts to select appropriate training data, the model is capable of generating harmful content, especially when prompted explicitly. We encourage the open-source community to engage in developing strategies to minimize such risks.
|
114 |
+
|
115 |
+
### Recommendations for Safe and Ethical Usage
|
116 |
+
|
117 |
+
- **Human Oversight:** We recommend incorporating a human curation layer or using filters to manage and improve the quality of outputs, especially in public-facing applications. This approach can help mitigate the risk of generating objectionable content unexpectedly.
|
118 |
+
|
119 |
+
- **Application-Specific Testing:** Developers intending to use Trendyol LLM should conduct thorough safety testing and optimization tailored to their specific applications. This is crucial, as the model’s responses can be unpredictable and may occasionally be biased, inaccurate, or offensive.
|
120 |
+
|
121 |
+
- **Responsible Development and Deployment:** It is the responsibility of developers and users of Trendyol LLM to ensure its ethical and safe application. We urge users to be mindful of the model's limitations and to employ appropriate safeguards to prevent misuse or harmful consequences.
|