Skip to content

Commit

Permalink
add part 3 to README and 5_hf.py
Browse files Browse the repository at this point in the history
  • Loading branch information
onlyphantom committed Apr 11, 2023
1 parent b039a4d commit 1fdf898
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
33 changes: 33 additions & 0 deletions 5_hf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from dotenv import load_dotenv
from langchain import HuggingFaceHub, LLMChain
from langchain.prompts import PromptTemplate

load_dotenv()

# hub_llm = HuggingFaceHub(repo_id="mrm8488/t5-base-finetuned-wikiSQL")

# prompt = PromptTemplate(
# input_variables=["question"],
# template="Translate English to SQL: {question}"
# )

# hub_chain = LLMChain(prompt=prompt, llm=hub_llm, verbose=True)
# print(hub_chain.run("What is the average age of the respondents using a mobile device?"))


# second example below:
hub_llm = HuggingFaceHub(
repo_id='gpt2',
model_kwargs={'temperature': 0.7, 'max_length': 100}
)

prompt = PromptTemplate(
input_variables=["profession"],
template="You had one job 😡! You're the {profession} and you didn't have to be sarcastic"
)

hub_chain = LLMChain(prompt=prompt, llm=hub_llm, verbose=True)
print(hub_chain.run("customer service agent"))
print(hub_chain.run("politician"))
print(hub_chain.run("Fintech CEO"))
print(hub_chain.run("insurance agent"))
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# llm-python
A set of instructional materials feature LLMs (GPT etc) through interfaces like llamaindex, langchain, Chroma, Alpaca etc.
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.

Also contain code and datasets for tutorial videos on LangChain on my YouTube channel:
- [LangChain + OpenAI tutorial: Building a Q&A system w/ own text data](https://youtu.be/DYOU_Z0hAwo)
<img src="assets/youtube.png" width="50%" alt="LangChain youtube tutorials" />

Learn LangChain from my YouTube channel:
- Part 1: [LangChain + OpenAI tutorial: Building a Q&A system w/ own text data](https://youtu.be/DYOU_Z0hAwo)
- Part 2: [LangChain + OpenAI to chat w/ (query) own Database / CSV](https://youtu.be/Fz0WJWzfNPI)
- Part 3: [LangChain + HuggingFace's Inference API (no OpenAI credits required!)](https://youtu.be/dD_xNmePdd0)
Binary file added assets/youtube.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1fdf898

Please sign in to comment.