forked from onlyphantom/llm-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b039a4d
commit 1fdf898
Showing
3 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.