LLM to Watch in 2023

abhinav singhal
3 min readAug 17, 2023

--

Hugging Face, LangChain, and Llama2

The world of artificial intelligence (AI) is constantly evolving, and one of the most exciting areas of research right now is large language models (LLMs). LLMs are AI systems that can generate text, translate languages, write different kinds of creative content, and answer your questions in an informative way.

In this article, I will introduce you to three LLM platforms that are worth watching in 2023: Hugging Face, LangChain, and Llama2.

Hugging Face

Hugging Face is a general-purpose platform for LLMs. It provides a wide variety of models, pre-trained on a variety of tasks, as well as tools for loading, evaluating, and using these models. Hugging Face is a good choice for projects that require a variety of LLM capabilities, or for projects that need to be portable across different platforms.

Here is an example of how you can use Hugging Face to generate text:

import transformers

model = transformers.AutoModelForSeq2SeqLM.from_pretrained("huggingface/transformers-xl")

prompt = "Write a poem about a cat."

output = model.generate(prompt=prompt, max_length=100)

print(output)

This code will generate a poem about a cat, using the Hugging Face Transformers library. The AutoModelForSeq2SeqLM class is used to load a pre-trained LLM model, and the generate() method is used to generate text from a prompt. The max_length parameter is used to specify the maximum number of tokens that the model should generate.

Here is an example of how you can use Hugging Face to translate languages:

import transformers

model = transformers.AutoModelForSeq2SeqLM.from_pretrained("huggingface/transformers-xl")

source_text = "This is a sentence in English."

target_language = "French"

output = model.generate(
prompt=source_text,
max_length=100,
target_lang=target_language,
)

print(output)

This code will translate the sentence “This is a sentence in English” into French, using the Hugging Face Transformers library. The AutoModelForSeq2SeqLM class is used to load a pre-trained LLM model, and the generate() method is used to generate text from a prompt. The max_length parameter is used to specify the maximum number of tokens that the model should generate. The target_lang parameter is used to specify the target language.

LangChain

LangChain is a platform specifically designed for conversational AI. It provides a number of features that are useful for building chatbots, such as dialogue management, natural language understanding, and text generation. LangChain is a good choice for projects that need to build a conversational AI system, or for projects that need to integrate an LLM into an existing chatbot.

Here is an example of how you can use LangChain to build a chatbot:

from langchain import Chatbot

bot = Chatbot()

bot.add_response("What's your name?", "My name is Bard.")
bot.add_response("What can you do?", "I can help you with a variety of tasks, such as answering questions, generating text, and translating languages.")

while True:
user_input = input("What can I do for you? ")
response = bot.respond(user_input)
print(response)

This code will create a chatbot that can respond to a variety of prompts. The Chatbot class is used to create a chatbot, and the add_response() method is used to add a response to the chatbot. The respond() method is used to generate a response to a prompt.

Llama2

Llama2 is an LLM that is specifically designed to be helpful and safe. It is trained on a dataset of text and code that is filtered for helpfulness and safety. Llama2 is a good choice for projects that need to generate text that is helpful and safe, such as customer service chatbots or educational applications.

Here is an example of how you can use Llama2 to answer questions:

import llama2

model = llama2.Llama2Model.from_pretrained("llama2/llama2

Summary:

  • If you need a platform with a wide variety of models and tools, Hugging Face is a good choice. 🚀
  • If you need a platform specifically designed for conversational AI, LangChain is a good choice. 🤖
  • If you need an LLM that is specifically designed to be helpful and safe, Llama2 is a good choice. 😇

--

--

abhinav singhal
abhinav singhal

Written by abhinav singhal

SE-Manager #Hiring #Mentorship #DEI #SoftwareDelivery #KPI #OKR #java-J2EE #Nodejs #GraphQl #Aws

No responses yet