Skip to content

This project explores various LLMs and embedding models using LangChain, integrating OpenAI, Hugging Face, Google Gemini, and Anthropic. It includes chat models, document similarity search, and embeddings with cosine similarity for retrieval. The setup is simple, making it easy to experiment with LLMs and vector search. πŸš€ (Big Thankyou to CampusX)

Notifications You must be signed in to change notification settings

04bhavyaa/langchain-models

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LangChain Models

This repository contains implementations of various Language Models (LLMs), Chat Models and Embedding Models using LangChain. It demonstrates different model integrations for LLMs and embeddings, including OpenAI, Hugging Face, Google, Sentence Transformers and Anthropic.

πŸ“‚ Directory Structure

04bhavyaa-langchain-models/
β”œβ”€β”€ README.md                  # Project documentation
β”œβ”€β”€ requirements.txt           # Required dependencies
β”œβ”€β”€ LLMs/
β”‚   └── llm_demo.py            # Basic LLM demonstration
β”œβ”€β”€ chat-models/               # Various chat models
β”‚   β”œβ”€β”€ chatmodel_anthropic.py # Anthropic's Claude integration
β”‚   β”œβ”€β”€ chatmodel_google.py    # Google Gemini (PaLM) integration
β”‚   β”œβ”€β”€ chatmodel_hf_api.py    # Hugging Face API integration
β”‚   β”œβ”€β”€ chatmodel_hf_local.py  # Local Hugging Face LLM integration
β”‚   └── chatmodel_openai.py    # OpenAI ChatGPT integration
└── embedding-models/          # Embedding models for similarity search
    β”œβ”€β”€ document_similarity.py # Cosine similarity for document search
    β”œβ”€β”€ embedding_hf_local.py  # Local Hugging Face embeddings
    β”œβ”€β”€ embedding_openai_docs.py # OpenAI document embeddings
    └── embedding_openai_query.py # OpenAI query embeddings

⚑ Tech Stack

  • LangChain (Core framework for chaining LLMs)
  • OpenAI API (ChatGPT & Embeddings)
  • Anthropic API (Claude models)
  • Google Generative AI (Gemini/PaLM models)
  • Hugging Face (Transformer-based LLMs & embeddings)
  • Scikit-learn (Cosine similarity for document search)
  • Pandas & NumPy (Data processing utilities)

🧠 Theory Behind LangChain Models

  • LLMs: These are large-scale neural networks trained on vast text corpora. LangChain provides a structured way to interact with them.
  • Chat Models: Variants of LLMs optimized for dialogue, such as OpenAI's ChatGPT, Claude, and Gemini.
  • Embedding Models: Convert text into high-dimensional vectors to perform similarity search, useful for document retrieval and semantic search.

πŸ”§ Setup Instructions

1. Clone the repository:

git clone https://github.com/yourusername/04bhavyaa-langchain-models.git
cd 04bhavyaa-langchain-models

2. Create and activate a virtual environment:

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

3. Install dependencies:

pip install -r requirements.txt

4. Set Up Environment Variables

Create a .env file and add your API keys:

OPENAI_API_KEY=your_openai_api_key
ANTHROPIC_API_KEY=your_anthropic_api_key
GOOGLE_API_KEY=your_google_api_key
HUGGINGFACEHUB_API_TOKEN=your_huggingface_api_key

5. Run the Models

Example usage for document similarity:

python embedding-models/document_similarity.py

Sample Output: image


πŸ’‘ Contributions are welcome! Feel free to fork, open issues, or submit PRs.

About

This project explores various LLMs and embedding models using LangChain, integrating OpenAI, Hugging Face, Google Gemini, and Anthropic. It includes chat models, document similarity search, and embeddings with cosine similarity for retrieval. The setup is simple, making it easy to experiment with LLMs and vector search. πŸš€ (Big Thankyou to CampusX)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages