Views
No views yet
README.md file for your iraqi_dialect_llm repository, including descriptions, usage instructions, and an example. Following this, I’ll show you how to set up a demo using Gradio to interact with the model.1# Iraqi Dialect Language Model
2
3This model is fine-tuned to generate text in the Iraqi Arabic dialect, making it suitable for applications such as text generation, conversational agents, and language-specific tasks in Iraqi Arabic. It has been trained on various sources, including Iraqi proverbs, dialogues, and other dialect-specific content.
4
5## Model Overview
6
7- **Model Name**: Iraqi Dialect LLM
8- **Base Model**: [aubmindlab/aragpt2-base](https://huggingface.co/aubmindlab/aragpt2-base)
9- **Language**: Iraqi Arabic
10- **Task**: Text generation, sentiment analysis, and general sentence construction in Iraqi dialect
11
12## Example Usage
13
14Below is an example of how to load and generate text with this model using Python and Hugging Face's `transformers` library.
15
16```python
17from transformers import AutoTokenizer, AutoModelForCausalLM
18
19# Load model and tokenizer
20tokenizer = AutoTokenizer.from_pretrained("EzioDevio/iraqi_dialect_llm")
21model = AutoModelForCausalLM.from_pretrained("EzioDevio/iraqi_dialect_llm")
22
23# Define a prompt
24prompt = "شلونك اليوم؟"
25
26# Encode the input
27inputs = tokenizer.encode(prompt, return_tensors="pt")
28
29# Generate text
30outputs = model.generate(inputs, max_length=50)
31generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
32
33print("Generated text:", generated_text)transformers and torch installed:pip install transformers torch
---
### Creating a Gradio Demo for Hugging Face Spaces
To create a demo using Gradio on Hugging Face Spaces, follow these steps:
1. **Prepare the App Code**:
Create a new Python file named `app.py` with the following code:
```python
import gradio as gr
from transformers import AutoTokenizer, AutoModelForCausalLM
# Load the model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("EzioDevio/iraqi_dialect_llm")
model = AutoModelForCausalLM.from_pretrained("EzioDevio/iraqi_dialect_llm")
# Define the text generation function
def generate_text(prompt):
inputs = tokenizer.encode(prompt, return_tensors="pt")
outputs = model.generate(inputs, max_length=50, num_return_sequences=1)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
# Set up the Gradio interface
iface = gr.Interface(
fn=generate_text,
inputs="text",
outputs="text",
title="Iraqi Dialect Language Model",
description="Generate text in Iraqi Arabic dialect.",
examples=["شلونك اليوم؟", "وين رايح؟", "صباح الخير"]
)
iface.launch()iraqi_dialect_demo.Gradio as the application type.app.py file and any additional files like requirements.txt (if you need specific dependencies listed).requirements.txt file in the Space:1transformers
2torch
3gradio