Skip to content

sarkanmagij/tilde-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

TildeOpen-30b Model Integration

A Python project for connecting to and interacting with the TildeAI/TildeOpen-30b language model via Hugging Face transformers.

About TildeOpen-30b

TildeOpen-30b is a 30B parameter open-source foundational language model built to serve underrepresented Nordic and Eastern European languages. It supports 34 languages including English, German, French, Polish, Russian, and many others, representing over 165 million speakers.

Key Features

  • ๐ŸŒ Multilingual: 34 European languages supported
  • ๐Ÿ”“ Open Source: CC-BY-4.0 license
  • โšก Optimized: Equitable tokenizer for fair language representation
  • ๐ŸŽฏ Focused: Specialized for Nordic and Eastern European languages
  • ๐Ÿ—๏ธ Enterprise Ready: Trained on LUMI supercomputer with 768 AMD MI250X GPUs

Quick Start

1. Installation

# Clone this repository
git clone <https://github.com/sarkanmagij/tilde-test>
cd tilde-test

# Install dependencies
pip3 install -r requirements.txt

2. Choose Your Approach

๐Ÿ““ Google Colab (Recommended for M2 Mac with 8GB RAM)

Open In Colab

  • โœ… Free GPU access
  • โœ… No local storage required
  • โœ… Full model capabilities
  • โœ… Interactive chat interface

๐Ÿ“ก API Demo (Zero Setup Required)

# Test immediately without any downloads
python3 tilde_api_demo.py
  • โœ… Uses Hugging Face Inference API
  • โœ… No model downloads
  • โœ… Works on any system
  • โœ… Immediate testing

๐Ÿš€ Minimal Demo (Local Exploration)

# Explore the model without downloading 60GB+ files
python3 tilde_minimal.py
  • โœ… Only downloads tokenizer (~2.3MB)
  • โœ… Works on any system
  • โœ… Demonstrates multilingual capabilities
  • โœ… Shows system requirements for full model

๐ŸŽฎ GPU Users (24GB+ VRAM)

# Full model with optimizations
python3 tilde_lightweight.py
  • โœ… 8-bit/4-bit quantization
  • โœ… Automatic memory management
  • โœ… Best performance/memory balance

๐Ÿ’ป CPU Users (32GB+ RAM)

# CPU-optimized version (very slow)
python3 tilde_cpu_friendly.py
  • โš ๏ธ Extremely slow on CPU
  • โš ๏ธ Requires significant RAM
  • ๐Ÿ’ก Cloud GPU recommended instead

๐Ÿ”ง Standard Approach (48GB+ GPU)

# Original full model loading
python3 tilde_model.py

๐Ÿงช Quick Test (Downloads full model)

# Test connection with full model download
python3 test_connection.py

Project Structure

tilde-test/
โ”œโ”€โ”€ README.md                    # This file
โ”œโ”€โ”€ requirements.txt             # Python dependencies
โ”œโ”€โ”€ tilde_minimal.py            # ๐Ÿš€ Minimal demo (tokenizer only, ~2MB download)
โ”œโ”€โ”€ tilde_lightweight.py        # ๐ŸŽฎ GPU optimized with quantization
โ”œโ”€โ”€ tilde_cpu_friendly.py       # ๐Ÿ’ป CPU optimized (slow, high RAM)
โ”œโ”€โ”€ tilde_model.py              # ๐Ÿ”ง Standard model interface
โ”œโ”€โ”€ test_connection.py          # ๐Ÿงช Full model connection test
โ”œโ”€โ”€ tilde_api_demo.py           # ๐Ÿ“ก API-based demo (zero downloads!)
โ”œโ”€โ”€ TildeOpen_30b_Colab.ipynb   # ๐Ÿ““ Google Colab notebook
โ”œโ”€โ”€ tilde_colab_optimized.py    # ๐Ÿš€ Colab-optimized script
โ”œโ”€โ”€ app.py                      # ๐ŸŒ Gradio web interface (HF Spaces)
โ”œโ”€โ”€ requirements_spaces.txt     # ๐Ÿ“ฆ Dependencies for HF Spaces
โ””โ”€โ”€ TildeOpen-30b-README.md     # Official model documentation

Dependencies

  • torch (โ‰ฅ2.0.0) - PyTorch framework
  • transformers (โ‰ฅ4.35.0) - Hugging Face transformers
  • accelerate (โ‰ฅ0.20.0) - Model acceleration
  • safetensors (โ‰ฅ0.3.0) - Safe tensor serialization
  • sentencepiece (โ‰ฅ0.1.99) - Tokenization (required for this model)
  • protobuf (โ‰ฅ3.20.0) - Protocol buffers

Lightweight Options (No 60GB Download!)

๐Ÿš€ Minimal Demo - Start Here!

Perfect for exploring TildeOpen-30b without massive downloads:

python3 tilde_minimal.py

What it does:

  • Downloads only the tokenizer (~2.3MB)
  • Demonstrates multilingual tokenization
  • Shows system requirements
  • Interactive tokenizer testing
  • Zero model weight downloads

Best for:

  • First-time exploration
  • Understanding model capabilities
  • Testing tokenization across 34 languages
  • Checking system compatibility

๐Ÿ’พ Memory-Optimized Loading

For users who want the full model with minimal memory usage:

python3 tilde_lightweight.py

Features:

  • Automatic quantization (4-bit/8-bit)
  • Streams model weights as needed
  • Adaptive memory management
  • GPU/CPU detection
  • Reduced storage requirements

Usage Examples

Basic Text Generation

from tilde_model import TildeOpenModel

# Initialize and load model
model = TildeOpenModel()
model.load_model()

# Generate text
response = model.generate_text("Hello, how are you today?", max_new_tokens=100)
print(response)

Interactive Chat

The tilde_model.py script provides an interactive chat interface:

python3 tilde_model.py

Features:

  • ๐Ÿ’ฌ Interactive conversation
  • ๐Ÿงน Clear conversation history with clear
  • ๐Ÿšช Exit with quit, exit, or q
  • ๐ŸŽ›๏ธ Configurable generation parameters

Direct Model Usage

from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

# Load tokenizer (use_fast=False is required!)
tokenizer = AutoTokenizer.from_pretrained("TildeAI/TildeOpen-30b", use_fast=False)

# Load model
model = AutoModelForCausalLM.from_pretrained(
    "TildeAI/TildeOpen-30b",
    torch_dtype=torch.bfloat16,
    device_map="auto"
)

# Generate
inputs = tokenizer("Your prompt here", return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=512)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)

System Requirements

Minimum Requirements

  • RAM: 32GB+ recommended (for 30B parameter model)
  • GPU: 24GB+ VRAM recommended (RTX 3090, RTX 4090, A100, etc.)
  • Storage: 65GB+ free space for model files
  • Python: 3.8+

Performance Notes

  • ๐Ÿ–ฅ๏ธ CPU Only: Will work but be extremely slow
  • ๐ŸŽฎ GPU Recommended: Significant performance improvement
  • โ˜๏ธ Cloud Options: Google Colab, Hugging Face Spaces, AWS, or similar for GPU access

๐Ÿš€ Cloud Deployment Options

๐Ÿ““ Google Colab (Recommended for M2 Mac users)

Perfect for your M2 Mac with 8GB RAM!

  1. Open the Colab Notebook: Open In Colab

  2. Enable GPU: Go to Runtime > Change runtime type > Select GPU

  3. Run all cells in order - the notebook includes:

    • Automatic dependency installation
    • Model loading with quantization
    • Interactive chat interface
    • Multilingual testing examples
  4. Alternative Colab Script:

    # Upload tilde_colab_optimized.py to Colab and run:
    python3 tilde_colab_optimized.py

๐Ÿค— Hugging Face Spaces

Deploy your own web interface:

  1. Fork this repository
  2. Create a new Space on Hugging Face
  3. Upload these files:
    • app.py (main Gradio interface)
    • requirements_spaces.txt (rename to requirements.txt)
    • README_spaces.md (rename to README.md)
  4. Set GPU hardware in Space settings
  5. Your web interface will be live!

โšก Quick Cloud Start

For immediate testing without setup:

# Use the API demo (no local downloads)
python3 tilde_api_demo.py

This uses Hugging Face's Inference API - zero setup required!

Supported Languages

Bulgarian, Croatian, Czech, Danish, Dutch, English, Estonian, Finnish, French, German, Hungarian, Icelandic, Irish, Italian, Latvian, Lithuanian, Macedonian, Maltese, Norwegian, Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, Turkish, Ukrainian, and more.

Model Performance

TildeOpen-30b shows excellent performance on underrepresented European languages compared to other large language models. See TildeOpen-30b-README.md for detailed benchmarks.

Troubleshooting

Common Issues

  1. SentencePiece Error: Install with pip install sentencepiece
  2. CUDA Out of Memory: Reduce batch size or use CPU
  3. Slow Generation: Ensure GPU is being used properly
  4. Model Download Fails: Check internet connection and disk space

GPU Setup

import torch
print(f"CUDA available: {torch.cuda.is_available()}")
print(f"GPU name: {torch.cuda.get_device_name() if torch.cuda.is_available() else 'None'}")

Contributing

Feel free to submit issues and enhancement requests!

License

This project is open source. The TildeOpen-30b model is licensed under CC-BY-4.0.

Links


Note: This is a foundational model not yet adapted for instruction following or safety alignment. The next version will be a specialized translation model.

About

No description, website, or topics provided.

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors