Top Related Projects
An implementation of model parallel autoregressive transformers on GPUs, based on the Megatron and DeepSpeed libraries
🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
TensorFlow code and pre-trained models for BERT
DeepSpeed is a deep learning optimization library that makes distributed training and inference easy, efficient, and effective.
Facebook AI Research Sequence-to-Sequence Toolkit written in Python.
🌸 Run LLMs at home, BitTorrent-style. Fine-tuning and inference up to 10x faster than offloading
Quick Overview
OLMo (Open Language Model) is an open-source language model and toolkit developed by AI2 (Allen Institute for AI). It aims to provide a fully open, reproducible, and customizable foundation for large language models, including pre-training, fine-tuning, and inference capabilities.
Pros
- Fully open-source, allowing for transparency and reproducibility in language model research
- Supports both pre-training and fine-tuning, enabling customization for specific tasks
- Includes a comprehensive toolkit for model development and experimentation
- Designed with scalability in mind, supporting distributed training across multiple GPUs
Cons
- Relatively new project, which may lead to potential instability or lack of extensive community support
- Requires significant computational resources for pre-training and fine-tuning large models
- Documentation may be less comprehensive compared to more established language model frameworks
- Limited pre-trained model options compared to some commercial alternatives
Code Examples
- Loading a pre-trained OLMo model:
from olmo import OLMoForCausalLM, OLMoTokenizer
model = OLMoForCausalLM.from_pretrained("allenai/OLMo-7B")
tokenizer = OLMoTokenizer.from_pretrained("allenai/OLMo-7B")
- Generating text with OLMo:
prompt = "The future of artificial intelligence is"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_length=100)
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(generated_text)
- Fine-tuning OLMo on a custom dataset:
from olmo import OLMoForCausalLM, Trainer, TrainingArguments
model = OLMoForCausalLM.from_pretrained("allenai/OLMo-7B")
trainer = Trainer(
model=model,
args=TrainingArguments(output_dir="./olmo-finetuned", num_train_epochs=3),
train_dataset=your_custom_dataset,
)
trainer.train()
Getting Started
To get started with OLMo, follow these steps:
-
Install OLMo using pip:
pip install olmo
-
Load a pre-trained model and tokenizer:
from olmo import OLMoForCausalLM, OLMoTokenizer model = OLMoForCausalLM.from_pretrained("allenai/OLMo-7B") tokenizer = OLMoTokenizer.from_pretrained("allenai/OLMo-7B")
-
Generate text:
prompt = "Hello, world!" inputs = tokenizer(prompt, return_tensors="pt") outputs = model.generate(**inputs, max_length=50) generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True) print(generated_text)
For more advanced usage, including pre-training and fine-tuning, refer to the official documentation and examples in the OLMo repository.
Competitor Comparisons
An implementation of model parallel autoregressive transformers on GPUs, based on the Megatron and DeepSpeed libraries
Pros of GPT-NeoX
- More extensive documentation and examples for training and fine-tuning
- Broader community support and contributions
- Designed for distributed training across multiple GPUs
Cons of GPT-NeoX
- Higher computational requirements for training
- Less focus on interpretability and analysis tools
- More complex setup process for beginners
Code Comparison
OLMo:
from olmo import OLMo
model = OLMo.from_pretrained("olmo-1b")
output = model.generate("Hello, world!")
GPT-NeoX:
from gpt_neox import GPTNeoX
model = GPTNeoX.from_pretrained("gpt-neox-20b")
output = model.generate("Hello, world!")
Both repositories provide similar high-level APIs for loading and using pre-trained models. However, GPT-NeoX offers more advanced features for distributed training and customization, while OLMo focuses on simplicity and ease of use for researchers and developers.
OLMo emphasizes interpretability and analysis tools, making it more suitable for research-oriented tasks. GPT-NeoX, on the other hand, is designed for large-scale training and deployment, making it a better choice for production environments and projects requiring significant computational resources.
🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
Pros of transformers
- Extensive model support: Includes a wide range of pre-trained models and architectures
- Active community: Large user base and frequent updates
- Comprehensive documentation: Detailed guides and examples for various tasks
Cons of transformers
- Complexity: Can be overwhelming for beginners due to its extensive features
- Resource intensive: Some models require significant computational resources
Code comparison
OLMo
from olmo import OLMoTokenizer, OLMoForCausalLM
tokenizer = OLMoTokenizer.from_pretrained("allenai/olmo-7b")
model = OLMoForCausalLM.from_pretrained("allenai/olmo-7b")
transformers
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("gpt2")
model = AutoModelForCausalLM.from_pretrained("gpt2")
Key differences
- OLMo focuses specifically on the OLMo model, while transformers supports a wide range of models
- transformers uses a more generalized
Auto
class for model and tokenizer loading - OLMo's API is tailored for its specific architecture, while transformers provides a unified interface for various models
TensorFlow code and pre-trained models for BERT
Pros of BERT
- Well-established and widely adopted in the NLP community
- Extensive documentation and pre-trained models available
- Proven performance on various NLP tasks
Cons of BERT
- Older architecture compared to more recent language models
- Limited context window size (typically 512 tokens)
- Requires fine-tuning for specific tasks
Code Comparison
BERT example:
from transformers import BertTokenizer, BertModel
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
model = BertModel.from_pretrained('bert-base-uncased')
OLMo example:
from olmo import OLMoTokenizer, OLMoForCausalLM
tokenizer = OLMoTokenizer.from_pretrained("allenai/OLMo-7B")
model = OLMoForCausalLM.from_pretrained("allenai/OLMo-7B")
Key Differences
- OLMo is a more recent model with potential for improved performance
- BERT uses bidirectional training, while OLMo is a unidirectional (left-to-right) model
- OLMo is designed for open-ended text generation, while BERT excels in understanding context
Use Cases
- BERT: Sentiment analysis, named entity recognition, question answering
- OLMo: Text generation, language modeling, conversational AI
DeepSpeed is a deep learning optimization library that makes distributed training and inference easy, efficient, and effective.
Pros of DeepSpeed
- More mature and widely adopted, with extensive documentation and community support
- Offers a broader range of optimization techniques and training acceleration methods
- Supports multiple deep learning frameworks, including PyTorch and TensorFlow
Cons of DeepSpeed
- More complex setup and configuration process
- Steeper learning curve for beginners
- May require more fine-tuning to achieve optimal performance
Code Comparison
OLMo:
from olmo import OLMo
model = OLMo.from_pretrained("allenai/olmo-7b")
output = model.generate("The capital of France is")
DeepSpeed:
import deepspeed
import torch
model, optimizer, _, _ = deepspeed.initialize(args=args,
model=model,
model_parameters=params)
output = model(input_ids)
Key Differences
- OLMo focuses on providing a simple API for large language models, while DeepSpeed offers a comprehensive suite of optimization tools
- DeepSpeed is framework-agnostic, whereas OLMo is primarily designed for PyTorch
- OLMo emphasizes ease of use for specific language tasks, while DeepSpeed aims to optimize general deep learning workloads
Facebook AI Research Sequence-to-Sequence Toolkit written in Python.
Pros of fairseq
- More established and mature project with a larger community
- Supports a wider range of NLP tasks and models
- Extensive documentation and examples
Cons of fairseq
- Larger codebase, potentially more complex to navigate
- May have more dependencies and setup requirements
- Less focused on specific language model architectures
Code Comparison
OLMo example:
from olmo import OLMo
model = OLMo.from_pretrained("olmo-1b")
output = model.generate("The quick brown fox")
fairseq example:
from fairseq.models.transformer_lm import TransformerLanguageModel
model = TransformerLanguageModel.from_pretrained("transformer_lm.gpt2.large")
output = model.generate("The quick brown fox", beam=5, sampling=True)
Both repositories provide high-level APIs for loading and using pre-trained models. OLMo appears to have a more streamlined interface specifically for language models, while fairseq offers more flexibility and options for various NLP tasks.
fairseq's codebase is more extensive, covering a broader range of models and tasks. OLMo, being more focused on large language models, may have a simpler structure for those specifically interested in LLMs.
Overall, the choice between these repositories depends on the specific requirements of the project and the desired balance between flexibility and specialization in language modeling.
🌸 Run LLMs at home, BitTorrent-style. Fine-tuning and inference up to 10x faster than offloading
Pros of Petals
- Focuses on distributed inference, allowing users to run large language models collaboratively
- Supports a wider range of models, including BLOOM and LLaMA
- Offers a unique approach to democratizing access to large language models
Cons of Petals
- Less emphasis on model training and fine-tuning compared to OLMo
- May have higher latency due to its distributed nature
- Potentially more complex setup for individual users
Code Comparison
OLMo:
from olmo import OLMo
model = OLMo.from_pretrained("allenai/olmo-7b")
output = model.generate("Hello, world!")
Petals:
from petals import AutoDistributedModelForCausalLM
model = AutoDistributedModelForCausalLM.from_pretrained("bigscience/bloom")
output = model.generate("Hello, world!")
Both repositories provide easy-to-use interfaces for working with large language models. OLMo focuses on a specific model and offers more control over training and fine-tuning, while Petals emphasizes distributed inference across a network of contributors. The code examples show similar usage patterns, but Petals' approach is geared towards distributed computing.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
OLMo: Open Language Model
OLMo is a repository for training and using AI2's state-of-the-art open language models. It is designed by scientists, for scientists.
Installation
First, install PyTorch following the instructions specific to your operating system.
For training and fine-tuning, we recommend installing from source:
git clone https://github.com/allenai/OLMo.git
cd OLMo
pip install -e .[all]
You can also install from PyPI with:
pip install ai2-olmo
Pretraining
OLMo pretraining follows a two-stage training procedure. In the first stage, we train on large amounts of mostly web-based data: OLMo-mix-1124 In the second stage, we train on a smaller amount of high-quality, targeted data: Dolmino-mix-1124
You can find all the checkpoints, at minimum every 1000 training steps, on Huggingface:
Steps to reproduce
To reproduce any of the training processes described below, run this:
torchrun --nproc_per_node=8 scripts/train.py {path_to_train_config}
For the training config, use any of the configs listed below.
If you want to override any of the settings in the training config without having to write a new config every time, you can do this:
torchrun --nproc_per_node=8 scripts/train.py {path_to_train_config} \
--setting1=value \
--setting2=value \
--setting3.subsetting1=value
The training configs below refer to training data that gets streamed in live over HTTP. To reproduce at large scale, we recommend downloading the files locally and changing the paths to point to your local file system.
Note: Some of the files that the training configs refer to are still being uploaded (as of 2024-11-27). They should all appear in the next few days as the uploads complete.
Stage 1
Stage 1 is the biggest stage, where we train on 4T or 5T tokens on largely web-based data.
OLMo2 7B | OLMo2 13B | |
---|---|---|
Number of tokens | 4 Trillion | 5 Trillion |
Checkpoint | stage1-step928646-tokens3896B | stage1-step596057-tokens5001B |
Training config | OLMo2-7B-stage1.yaml | OLMo2-13B-stage1.yaml |
WandB | wandb.ai/â¦/OLMo2-7B (link to come) | wandb.ai/â¦/OLMo2-13B (link to come) |
Stage 2 for the 7B
For the 7B model, we train three times with different data order on 50B high quality tokens, and then average ("soup") the models.
Checkpoint | Training config | WandB | |
---|---|---|---|
random seed 42 | stage2-ingredient1-step11931-tokens50B | OLMo2-7B-stage2-seed42.yaml | link to come |
random seed 42069 | stage2-ingredient2-step11931-tokens50B | OLMo2-7B-stage2-seed42069.yaml | link to come |
random seed 666 | stage2-ingredient3-step11931-tokens50B | OLMo2-7B-stage2-seed666.yaml | link to come |
final souped model | main | no config, we just averaged the weights in Python |
The training configs linked here are set up to download the latest checkpoint after stage 1, and start training from there.
Stage 2 for the 13B
For the 13B model, we train three times with different data order on 100B high quality tokens, and one more time on 300B high quality tokens. Then we average ("soup") the models.
Checkpoint | Training config | WandB | |
---|---|---|---|
random seed 1110, 100B | stage2-ingredient1-step11931-tokens100B | OLMo2-13B-stage2-seed1110-100B.yaml | link to come |
random seed 2662, 100B | stage2-ingredient2-step11931-tokens100B | OLMo2-13B-stage2-seed2662-100B.yaml | link to come |
random seed 6209, 100B | stage2-ingredient3-step11931-tokens100B | OLMo2-13B-stage2-seed6209-100B.yaml | link to come |
random seed 2662, 300B | stage2-ingredient4-step11931-tokens300B | OLMo2-13B-stage2-seed2662-300B.yaml | link to come |
final souped model | main | no config, we just averaged the weights in Python |
The training configs linked here are set up to download the latest checkpoint after stage 1, and start training from there.
Instruction tuned variants
For instruction tuned variants of these models, go to
Inference
You can use our Hugging Face integration to run inference on the OLMo Transformers checkpoints:
from transformers import AutoModelForCausalLM, AutoTokenizer
olmo = AutoModelForCausalLM.from_pretrained("allenai/OLMo-2-1124-7B")
tokenizer = AutoTokenizer.from_pretrained("allenai/OLMo-2-1124-7B")
message = ["Language modeling is "]
inputs = tokenizer(message, return_tensors='pt', return_token_type_ids=False)
# optional verifying cuda
# inputs = {k: v.to('cuda') for k,v in inputs.items()}
# olmo = olmo.to('cuda')
response = olmo.generate(**inputs, max_new_tokens=100, do_sample=True, top_k=50, top_p=0.95)
print(tokenizer.batch_decode(response, skip_special_tokens=True)[0])
Alternatively, with the Hugging Face pipeline abstraction:
from transformers import pipeline
olmo_pipe = pipeline("text-generation", model="allenai/OLMo-2-1124-7B")
print(olmo_pipe("Language modeling is"))
Quantization
olmo = AutoModelForCausalLM.from_pretrained("allenai/OLMo-2-1124-7B", torch_dtype=torch.float16, load_in_8bit=True) # requires bitsandbytes
The quantized model is sensitive to input types and CUDA handling. To avoid potential issues, we recommend explicitly converting input IDs to CUDA using: inputs.input_ids.to('cuda')
Evaluation
Additional tools for evaluating OLMo models are available at the OLMo Eval repo.
Citing
@article{OLMo,
title={OLMo: Accelerating the Science of Language Models},
author={Dirk Groeneveld and Iz Beltagy and Pete Walsh and Akshita Bhagia and Rodney Kinney and Oyvind Tafjord and A. Jha and Hamish Ivison and Ian Magnusson and Yizhong Wang and Shane Arora and David Atkinson and Russell Authur and Khyathi Raghavi Chandu and Arman Cohan and Jennifer Dumas and Yanai Elazar and Yuling Gu and Jack Hessel and Tushar Khot and William Merrill and Jacob Daniel Morrison and Niklas Muennighoff and Aakanksha Naik and Crystal Nam and Matthew E. Peters and Valentina Pyatkin and Abhilasha Ravichander and Dustin Schwenk and Saurabh Shah and Will Smith and Emma Strubell and Nishant Subramani and Mitchell Wortsman and Pradeep Dasigi and Nathan Lambert and Kyle Richardson and Luke Zettlemoyer and Jesse Dodge and Kyle Lo and Luca Soldaini and Noah A. Smith and Hanna Hajishirzi},
year={2024},
url={https://api.semanticscholar.org/CorpusID:267365485},
journal={arXiv preprint},
}
Top Related Projects
An implementation of model parallel autoregressive transformers on GPUs, based on the Megatron and DeepSpeed libraries
🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
TensorFlow code and pre-trained models for BERT
DeepSpeed is a deep learning optimization library that makes distributed training and inference easy, efficient, and effective.
Facebook AI Research Sequence-to-Sequence Toolkit written in Python.
🌸 Run LLMs at home, BitTorrent-style. Fine-tuning and inference up to 10x faster than offloading
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot