Downloads Β· 30 days
36
9% of all-time downloads
Ali0044/LinguaFlow
LinguaFlow is a translation model from Ali0044. Use it when you need text moved from one language to another. It is set up for keras. The card lists the license as mit.
<div align="center" <img src="banner.png" alt="LinguaFlow Banner" width="100%"
Downloads Β· 30 days
36
9% of all-time downloads
All-time downloads
411
Public
Repo size
598 MB
Likes
1
Public
Click a slice to open those files.
.keras199 MB Β· 98%
From the Hugging Face model README
LinguaFlow is a robust Sequence-to-Sequence (Seq2Seq) neural machine translation model specialized in converting English text into Arabic. Leveraging a deep learning architecture based on LSTM (Long Short-Term Memory), it captures complex linguistic relationships and contextual nuances to provide high-quality translations for short-to-medium length sentences.
salehalmansour/english-to-arabic-translate dataset.The model employs an Encoder-Decoder topology designed for sequence transduction tasks.
graph LR
A[English Input Sequence] --> B[Embedding Layer]
B --> C[LSTM Encoder]
C --> D[Context Vector]
D --> E[Repeat Vector]
E --> F[LSTM Decoder]
F --> G[Dense Layer / Softmax]
G --> H[Arabic Output Sequence]
| Component | Specification |
|---|---|
| Model Type | Seq2Seq LSTM |
| Hidden Units | 512 |
| Embedding Size | 512 |
| Input Depth | 20 Timesteps |
| Output Depth | 20 Timesteps |
| Optimizer | Adam |
| Loss Function | Sparse Categorical Crossentropy |
LinguaFlow demonstrates strong generalization capabilities on the validation set after extensive training.
| Metric | Training | Validation |
|---|---|---|
| Accuracy | 85.99% | 85.74% |
| Loss | 0.9594 | 1.1926 |
pip install tensorflow numpy pandas scikit-learn huggingface_hub
from huggingface_hub import snapshot_download
import tensorflow as tf
import numpy as np
import os
import pickle
from tensorflow.keras.preprocessing.sequence import pad_sequences
# 1. Download model and tokenizers
repo_id = "Ali0044/LinguaFlow"
local_dir = snapshot_download(repo_id=repo_id)
# 2. Load resources
model = tf.keras.models.load_model(os.path.join(local_dir, "Translation_model.keras"))
with open(os.path.join(local_dir, "eng_tokenizer.pkl"), "rb") as f:
eng_tokenizer = pickle.load(f)
with open(os.path.join(local_dir, "ar_tokenizer.pkl"), "rb") as f:
ar_tokenizer = pickle.load(f)
# 3. Translation Function
def translate(sentences):
# Clean and tokenize
seq = eng_tokenizer.texts_to_sequences(sentences)
# Pad sequences
padded = pad_sequences(seq, maxlen=20, padding='post')
# Predict
preds = model.predict(padded)
preds = np.argmax(preds, axis=-1)
results = []
for s in preds:
text = [ar_tokenizer.index_word[i] for i in s if i != 0]
results.append(' '.join(text))
return results
# 4. Try it out!
print(translate(["Hello, how are you?"]))
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.