├── requirements.txt ├── Dockerfile ├── bittensor_integration └── neuron.py ├── model └── translator.py └── README.md /requirements.txt: -------------------------------------------------------------------------------- 1 | torch 2 | transformers 3 | bittensor -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.10 2 | 3 | # Set working directory 4 | WORKDIR /app 5 | 6 | # Install dependencies 7 | COPY requirements.txt . 8 | RUN pip install --no-cache-dir -r requirements.txt 9 | 10 | # Copy project files 11 | COPY . /app 12 | 13 | # Expose any necessary ports 14 | EXPOSE 8080 15 | 16 | # Run the Bittensor neuron 17 | CMD ["python", "bittensor_integration/neuron.py"] -------------------------------------------------------------------------------- /bittensor_integration/neuron.py: -------------------------------------------------------------------------------- 1 | import bittensor as bt 2 | from model.translator import SomaliTranslator 3 | 4 | 5 | class SomaliTranslatorNeuron(bt.Neuron): 6 | def __init__(self): 7 | super().__init__() 8 | # Initialize Somali Translator 9 | self.translator = SomaliTranslator() 10 | print("Somali Translator Neuron Initialized") 11 | 12 | def forward(self, synapse: bt.Synapse): 13 | try: 14 | # Get input text from synapse 15 | somali_text = synapse.text 16 | print(f"Received Input: {somali_text}") 17 | 18 | # Perform translation 19 | english_translation = self.translator.translate(somali_text) 20 | 21 | # Set the output to the translation 22 | synapse.output = english_translation 23 | print(f"Translated Output: {english_translation}") 24 | except Exception as e: 25 | synapse.output = "Error processing the input" 26 | print(f"Error: {e}") 27 | 28 | 29 | if __name__ == "__main__": 30 | neuron = SomaliTranslatorNeuron() 31 | neuron.run() 32 | -------------------------------------------------------------------------------- /model/translator.py: -------------------------------------------------------------------------------- 1 | from transformers import M2M100ForConditionalGeneration, M2M100Tokenizer 2 | 3 | 4 | class SomaliTranslator: 5 | def __init__(self, model_name="facebook/m2m100_418M"): 6 | # Load pre-trained model and tokenizer 7 | self.model_name = model_name 8 | self.tokenizer = M2M100Tokenizer.from_pretrained(self.model_name) 9 | self.model = M2M100ForConditionalGeneration.from_pretrained( 10 | self.model_name) 11 | print("Somali-English Translator Model Loaded Successfully") 12 | 13 | def translate(self, somali_text: str) -> str: 14 | try: 15 | # Set source and target languages 16 | self.tokenizer.src_lang = "so" # Somali 17 | encoded_input = self.tokenizer(somali_text, return_tensors="pt") 18 | 19 | # Generate translation 20 | generated_tokens = self.model.generate( 21 | **encoded_input, 22 | forced_bos_token_id=self.tokenizer.get_lang_id("en") # English 23 | ) 24 | english_translation = self.tokenizer.decode( 25 | generated_tokens[0], 26 | skip_special_tokens=True 27 | ) 28 | 29 | return english_translation 30 | except Exception as e: 31 | return f"Error during translation: {e}" 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # somTAO: Bringing Somali Language to Life with AI and Blockchain 2 | 3 | ## Overview 4 | **somTAO** is an AI-powered translator dedicated to advancing the Somali language in the digital world. By leveraging Facebook's **M2M100_418M model**, somTAO enables seamless **Somali-to-English translations** while contributing to the decentralized AI ecosystem of the **Bittensor blockchain**. As a neuron within the Bittensor network, somTAO showcases how AI can preserve, elevate, and integrate Somali language into cutting-edge technology. 5 | 6 | ## What somTAO Does 7 | - **Empowering Somali Language**: Brings the Somali language to global platforms through accurate AI-driven translations. 8 | - **AI-Powered Translation**: Seamlessly translates Somali text into natural and fluent English. 9 | - **Blockchain Integration**: Operates on the decentralized **Bittensor blockchain**, showcasing the power of AI in blockchain networks. 10 | - **Global Accessibility**: Enables Somali speakers to interact with AI tools and services on a global scale. 11 | 12 | ## Key Features 13 | - **Preserving Somali Identity**: Focuses on enhancing and preserving the Somali language through advanced AI solutions. 14 | - **AI for Inclusion**: Ensures linguistic inclusivity by bridging the gap between Somali and English. 15 | - **Decentralized Contribution**: Runs as a scalable and autonomous node on the Bittensor blockchain, supporting decentralized AI advancements. 16 | - **Efficiency and Reliability**: Optimized for consistent, lightweight performance with high-quality results. 17 | 18 | ## Why somTAO? 19 | **somTAO** bridges the gap between technology and the Somali language, ensuring its presence in the digital and decentralized AI world. By leveraging blockchain technology, somTAO brings Somali to the forefront of innovation, empowering individuals, businesses, and communities to embrace AI-driven solutions while preserving linguistic heritage. 20 | 21 | --- 22 | 23 | **somTAO: Elevating the Somali Language with AI and Blockchain 🚀** --------------------------------------------------------------------------------