Large Language Models (LLMs) have taken over the artificial intelligence scene for some time, and it’s amazing. With the capability to mimic human conversation, many small to big companies try to develop their own LLMs.
Luckily, many companies and developers provide their LLMs as open-source and publicly available. It ranges from a lightweight to use to a massive parameterized model. What are some recommended open LLMs you should try? Let’s take a look.
DLite V2
AI Squared has announced the DLite V2 family of large language models (LLMs), designed to democratize AI technologies by making them accessible and usable for all.
Like the DLite V1 models, these lightweight LLMs range from 124 million to 1.5 billion parameters, exhibiting interactivity similar to ChatGPT. The V2 models, trained on the databricks-dolly-15k dataset, are licensed for commercial use, a departure from the V1 models, only available for research purposes.
The models are also cost-efficient to train and deploy, capable of running on a single T4 GPU. AI Squared has made the training dataset and models available on HuggingFace for public use. While not delivering state-of-the-art performance, the DLite V2 models offer the flexibility for organizations to fine-tune them for specific tasks with their own data.
Let’s try to use the models in our own environment. Because the model is hosted in HuggingFace, let’s install the transformers package initially.
pip install transformers
Using the transformers package, we can try out the model.
from transformers import pipeline
# Create the DLite pipeline
DLite = pipeline(model='aisquared/dlite-v2-1_5b', trust_remote_code=True)
# Use DLite on a prompt
prompt = 'How are you today?'
response = DLite(prompt)
# Print DLite's response
print(response)
Try to play around with the model yourself!
RedPajama
RedPajama is a project that aims to create leading LLMs open-source model by developing the RedPajama dataset that is used by many developers. The project also developed its own first models that trained on the RedPajama base dataset.
Among the released models are a 3 billion (3B) and a 7 billion (7B) parameter base model. The 3B model is particularly noteworthy as the most powerful and compact enough to run on older hardware.
The instruction-tuned versions of the models perform strongly on HELM benchmarks, making them suitable for downstream applications such as few-shot, entity extraction, classification, or summarization tasks. The 7B model, despite being 80% complete, already outperforms the Pythia 7B model, emphasizing the importance of larger datasets like RedPajama.
The table below summarizes the RedPajama model release, which has its own usage.
You can access the models using the following links:
Let’s try out one of the models. For this example, I would use the RedPajama BASE-3B model, which can be used in the CPU.
import torch
import transformers
from transformers import AutoTokenizer, AutoModelForCausalLM'
# init
tokenizer = AutoTokenizer.from_pretrained("togethercomputer/RedPajama-INCITE-Base-3B-v1")
model = AutoModelForCausalLM.from_pretrained("togethercomputer/RedPajama-INCITE-Base-3B-v1", torch_dtype=torch.bfloat16)
# infer
prompt = "Alan Turing is"
inputs = tokenizer(prompt, return_tensors='pt').to(model.device)
input_length = inputs.input_ids.shape[1]
outputs = model.generate(
**inputs, max_new_tokens=128, do_sample=True, temperature=0.7, top_p=0.7, top_k=50, return_dict_in_generate=True
)
token = outputs.sequences[0, input_length:]
output_str = tokenizer.decode(token)
print(output_str)
The result above comes from the prompt “Alan Turing is”, which is proven accurate.
Dolly 2.0
Dolly is an open-source LLM released by Databrick trained on the databricks-dolly-15k dataset specifically designed for instruction tuning large language models. The model can do various tasks, including brainstorming, classification, closed QA, generation, information extraction, open QA, and summarization.
Dolly 2.0 model itself is based on EleutherAI’s pythia-12b, which shows excellent performance on the prompt instruction behavior but provides a better result as it’s trained on the high-quality dataset curated by humans.
Let’s try out the model.
import torch
from transformers import pipeline
generate_text = pipeline(model="databricks/dolly-v2-12b", torch_dtype=torch.bfloat16, trust_remote_code=True, device_map="auto")
With the model ready, let’s see the result.
Conclusion
Large Language Model has taken over the world, and now many of them are available for free use. Here I list some of the Open-Source LLM you should try, including:
DLiteV2
RedPajama
Dolly 2.0
I hope it helps!