CoolFace
Apppublic

lakshyaag/w4d1-pg-rag

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
App README

Week 4: Tuesday

In today's assignment, we'll be creating an Open Source LLM-powered LangChain RAG Application in Chainlit.

There are 2 main sections to this assignment:

Build ๐Ÿ—๏ธ

Build Task 1: Deploy LLM and Embedding Model to SageMaker Endpoint Through Hugging Face Inference Endpoints

LLM Endpoint

Select "Inference Endpoint" from the "Solutions" button in Hugging Face:

image

Create a "+ New Endpoint" from the Inference Endpoints dashboard.

image

Select the NousResearch/Meta-Llama-3-8B-Instruct model repository and name your endpoint. Select N. Virginia as your region (us-east-1). Give your endpoint an appropriate name. Make sure to select at least a L4 GPU.

image

Select the following settings for your Advanced Configuration.

image

Create a Protected endpoint.

image

If you were successful, you should see the following screen:

image

Embedding Model Endpoint

We'll be using Snowflake/snowflake-arctic-embed-m for our embedding model today.

The process is the same as the LLM - but we'll make a few specific tweaks:

Let's make sure our set-up reflects the following screenshots:

image

After which, make sure the advanced configuration is set like so:

image

#### NOTE: PLEASE SHUTDOWN YOUR INSTANCES WHEN YOU HAVE COMPLETED THE ASSIGNMENT TO PREVENT UNESSECARY CHARGES

Build Task 2: Create RAG Pipeline with LangChain

Follow the notebook to create a LangChain pipeline powered by Hugging Face endpoints!

Once you're done - please move on to Build Task 3!

Build Task 3: Create a Chainlit Application

  1. 1.Create a new empty Docker space through Hugging Face - with the following settings:

image

NOTE: You may notice the application builds slowly (~15min.) with the default free-tier hardware. The process will be faster using the CPU upgrade Space Hardware - though it is not required.
  1. 1.Clone the newly created space into a directory that is NOT IN YOUR AI MAKERSPACE REPOSITORY using the SSH option.
NOTE: You may need to ensure you've added your SSH key to Hugging Face, as well as GitHub. This should already be done.

image

  1. 1.Copy and Paste (cp ... or through UI) the contents of Week 4/Day 1 into the newly cloned repository.
NOTE: Please keep the README.md that was cloned from your space and delete the class README.md.
  1. 1.Using the ls command or the tree command verify that you have copied over:
  • โ€”app.py
  • โ€”Dockerfile
  • โ€”data/paul_graham_essays.txt
  • โ€”chainlit.md
  • โ€”.gitignore
  • โ€”.env.sample
  • โ€”solution_app.py
  • โ€”requirements.txt

Here is an example as the ls -al CLI command:

image

  1. 1.Work through the app.py file to migrate your LCEL LangChain RAG Chain from the Notebook to Chainlit!
  1. 1.Be sure to modify your README.md and chainlit.md as you see fit!
NOTE: If you get stuck, there is a working reference version in solution_app.py.
  1. 1.When you are done with local testing - push your changes to your space.
  1. 1.Make sure you add your HF_LLM_ENDPOINT, HF_EMBED_ENDPOINT, HF_TOKEN as "Secrets" in your Hugging Face Space.

Terminating Your Resources

Please head to the settings of each endpoint and select Delete Endpoint. You will need to type the name of the endpoint to delete the resources.

Deliverables

  • โ€”Completed Notebook
  • โ€”Chainlit Application in a Hugging Face Space Powered by Hugging Face Endpoints
  • โ€”Screenshot of endpoint usage

Example Screen Shot:

image

Ship ๐Ÿšข

Create a Hugging Face Space powered by Hugging Face Endpoints!

Deliverables

  • โ€”A short Loom of the space, and a 1min. walkthrough of the application in full

Share ๐Ÿš€

Make a social media post about your final application!

Deliverables

  • โ€”Make a post on any social media platform about what you built!

Here's a template to get you started:

๐Ÿš€ Exciting News! ๐Ÿš€

I am thrilled to announce that I have just built and shipped a open-source LLM-powered Retrieval Augmented Generation Application with LangChain! ๐ŸŽ‰๐Ÿค–

๐Ÿ” Three Key Takeaways:
1๏ธโƒฃ 
2๏ธโƒฃ 
3๏ธโƒฃ 

Let's continue pushing the boundaries of what's possible in the world of AI and question-answering. Here's to many more innovations! ๐Ÿš€
Shout out to @AIMakerspace !

#LangChain #QuestionAnswering #RetrievalAugmented #Innovation #AI #TechMilestone

Feel free to reach out if you're curious or would like to collaborate on similar projects! ๐Ÿค๐Ÿ”ฅ
#### NOTE: PLEASE SHUTDOWN YOUR INSTANCES WHEN YOU HAVE COMPLETED THE ASSIGNMENT TO PREVENT UNESSECARY CHARGES