lakshyaag/w4d1-pg-rag
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:

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

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.

Select the following settings for your Advanced Configuration.

Create a Protected endpoint.

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

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:

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

#### 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
- Create a new empty Docker space through Hugging Face - with the following settings:

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.- 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.

- Copy and Paste (
cp ...or through UI) the contents ofWeek 4/Day 1into the newly cloned repository.
NOTE: Please keep theREADME.mdthat was cloned from your space and delete the classREADME.md.
- Using the
lscommand or thetreecommand verify that you have copied over:
app.pyDockerfiledata/paul_graham_essays.txtchainlit.md.gitignore.env.samplesolution_app.pyrequirements.txt
Here is an example as the ls -al CLI command:

- Work through the
app.pyfile to migrate your LCEL LangChain RAG Chain from the Notebook to Chainlit!
- Be sure to modify your
README.mdandchainlit.mdas you see fit!
NOTE: If you get stuck, there is a working reference version in solution_app.py.- When you are done with local testing - push your changes to your space.
- Make sure you add your
HF_LLM_ENDPOINT,HF_EMBED_ENDPOINT,HF_TOKENas "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:

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
