Skip to content

Commit 1fdf898

Browse files
committed
add part 3 to README and 5_hf.py
1 parent b039a4d commit 1fdf898

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

5_hf.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from dotenv import load_dotenv
2+
from langchain import HuggingFaceHub, LLMChain
3+
from langchain.prompts import PromptTemplate
4+
5+
load_dotenv()
6+
7+
# hub_llm = HuggingFaceHub(repo_id="mrm8488/t5-base-finetuned-wikiSQL")
8+
9+
# prompt = PromptTemplate(
10+
# input_variables=["question"],
11+
# template="Translate English to SQL: {question}"
12+
# )
13+
14+
# hub_chain = LLMChain(prompt=prompt, llm=hub_llm, verbose=True)
15+
# print(hub_chain.run("What is the average age of the respondents using a mobile device?"))
16+
17+
18+
# second example below:
19+
hub_llm = HuggingFaceHub(
20+
repo_id='gpt2',
21+
model_kwargs={'temperature': 0.7, 'max_length': 100}
22+
)
23+
24+
prompt = PromptTemplate(
25+
input_variables=["profession"],
26+
template="You had one job 😡! You're the {profession} and you didn't have to be sarcastic"
27+
)
28+
29+
hub_chain = LLMChain(prompt=prompt, llm=hub_llm, verbose=True)
30+
print(hub_chain.run("customer service agent"))
31+
print(hub_chain.run("politician"))
32+
print(hub_chain.run("Fintech CEO"))
33+
print(hub_chain.run("insurance agent"))

README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# llm-python
2-
A set of instructional materials feature LLMs (GPT etc) through interfaces like llamaindex, langchain, Chroma, Alpaca etc.
2+
A set of instructional materials, code samples and Python scripts featuring LLMs (GPT etc) through interfaces like llamaindex, langchain, Chroma, Alpaca etc. Mainly used to store reference code for my LangChain tutorials on YouTube.
33

4-
Also contain code and datasets for tutorial videos on LangChain on my YouTube channel:
5-
- [LangChain + OpenAI tutorial: Building a Q&A system w/ own text data](https://youtu.be/DYOU_Z0hAwo)
4+
<img src="assets/youtube.png" width="50%" alt="LangChain youtube tutorials" />
5+
6+
Learn LangChain from my YouTube channel:
7+
- Part 1: [LangChain + OpenAI tutorial: Building a Q&A system w/ own text data](https://youtu.be/DYOU_Z0hAwo)
8+
- Part 2: [LangChain + OpenAI to chat w/ (query) own Database / CSV](https://youtu.be/Fz0WJWzfNPI)
9+
- Part 3: [LangChain + HuggingFace's Inference API (no OpenAI credits required!)](https://youtu.be/dD_xNmePdd0)

assets/youtube.png

350 KB
Loading

0 commit comments

Comments
 (0)