---
language:
- tr
pipeline_tag: text-generation
license: apache-2.0
---


# **Trendyol LLM v4.1.0**
Trendyol LLM v4.1.0 is a generative model based on Trendyol LLM base v4.0 (continued pretraining version of [Qwen2.5 7B](https://huggingface.co/Qwen/Qwen2.5-7B) on 13 billion tokens) model. This is the repository for the chat model.

Keynotes:
- E-commerce knowledge improved
  - Description generation
  - Attribute extraction
  - Summarization
  - Fashion dialogues
  - Product tagging extraction
  - Category detection
  - Persona interpretation based on actions
  - RAG
  - etc.
- Improved Turkish language knowledge
- Function call support (partially completed. It will be completed on the next iterations.)

## Usage
```python
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
import torch


model_id = "Trendyol/Trendyol-LLM-7B-chat-v4.1.0"

pipe = pipeline(
    "text-generation",
    model=model_id,
    model_kwargs={
        "torch_dtype": torch.bfloat16,
        "use_cache":True, 
        "use_flash_attention_2": True
    },
    device_map='auto',
)


sampling_params = dict(do_sample=True, temperature=0.3, top_k=50, top_p=0.9, repetition_penalty=1.1)
DEFAULT_SYSTEM_PROMPT = "Sen yardımsever bir asistansın ve sana verilen talimatlar doğrultusunda en iyi cevabı üretmeye çalışacaksın."

messages = [
    {"role": "system", "content": DEFAULT_SYSTEM_PROMPT},
    {"role": "user", "content": "Türkiye'de kaç il var?"}
]

outputs = pipe(
    messages,
    max_new_tokens=1024,
    return_full_text=False,
    **sampling_params
)

print(outputs[0]["generated_text"])
```

### Function calling example
```python
tools = [
    {
        "name": "get_city_count",
        "description": "Get current city count of given country.",
        "parameters": {
            "type": "object",
            "properties": {
                "country_name": {
                    "type": "string",
                    "description": 'The name of the country to get the count for.',
                },
            },
            "required": ["country_name"],
        },
    },
    {
        "name": "get_temperature_date",
        "description": "Get temperature at a location and date.",
        "parameters": {
            "type": "object",
            "properties": {
                "location": {
                    "type": "string",
                    "description": 'The location to get the temperature for, in the format "City, State, Country".',
                },
                "date": {
                    "type": "string",
                    "description": 'The date to get the temperature for, in the format "Year-Month-Day".',
                },
                "unit": {
                    "type": "string",
                    "enum": ["celsius", "fahrenheit"],
                    "description": 'The unit to return the temperature in. Defaults to "celsius".',
                },
            },
            "required": ["location", "date"],
        },
    },
]

messages = [
    {"role": "system", "content": "Sen, aşağıdaki fonksiyonlara erişimi olan yardımcı bir asistansın. Gerektiğinde bunları kullanabilirsin -"},
    {"role": "user", "content": "Türkiye'de kaç il var?"}
]

text = pipe.tokenizer.apply_chat_template(messages, tools=tools, add_generation_prompt=True, tokenize=False)
inputs = pipe.tokenizer(text, return_tensors="pt").to(pipe.model.device)
outputs = pipe.model.generate(**inputs, max_new_tokens=512)
output_text = pipe.tokenizer.batch_decode(outputs)[0][len(text):]
print(output_text)
# '<function>{"name": "get_city_count", "arguments": \'{"country_name": "Turkey"}\'}</function><|im_end|>'
```

## Limitations, Risks, Bias, and Ethical Considerations
### Limitations and Known Biases
- **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.
- **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.
- **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.
### Risks and Ethical Considerations
- **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.
- **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.
- **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.
### Recommendations for Safe and Ethical Usage
- **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.
- **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.
- **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.