Build on large language models faster
Project description
Llama
Stop prompt tuning. Create your own Generative AI.
Installation
pip install llama-llm
Setup your keys
Go to powerml.co. Log in to get you API key and purchase credits.
Create ~/.powerml/configure_llama.yaml
and put a key in it.
production:
key: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
Define the LLM interface
Define the input and output types. Don't forget the context. They help the LLM understand the data.
class Tweet(Type):
tweet: str = Context("a viral tweet")
likes: int = Context("likes the tweet gets")
retweets: int = Context("retweets the tweet gets")
class User(Type):
username: str = Context("a user's handle on twitter")
Instantiate an LLM engine
from llama import LLM
llm = LLM(name="feedback")
Use the LLM to generate something new
user = User(username="llamas4sale") example_tweet = llm(user, output_type=Tweet)
print("tweet before training", example_tweet)
Train the LLM on your data
data = [
[User(username="i_heart_llamas"), Tweet(tweet="I like llamas", likes=5, retweets=3)],
[User(username="llamas4ever"), Tweet(tweet="I like llamas so much", likes=8, retweets=5)]
]
llm.add_data(data)
example_tweet = llm(user, output_type=Tweet)
print("Tweet after adding data", example_tweet)
Look at the results, and add your feedback to improve the LLM
llm.improve(on="tweet", to="have more {likes}")
llm.improve(on="tweet", to="have over 100 {retweets}")
llm.improve(
on="tweet",
to="make it shorter",
good_examples=[
Tweet(
tweet="Move over cats and dogs, llamas are the new internet sensation! These furry and friendly creatures have captured our hearts and become the most adorable animals on the planet! From their soft wool to their quirky personalities, llamas are simply irresistible! #llamalove #cuteoverload 🦙💕🌟",
likes=13452,
retweets=9724,
)
],
bad_examples=[
Tweet(
tweet="Good evening everyone, I hope you're all having a lovely day. I was taking a walk in the countryside earlier and happened to come across a group of llamas. Llamas are interesting animals with a long history of domestication by indigenous people in South America. They're known for their wool, which is used to make various textiles, and also for their use as pack animals. Although some people may find llamas cute and quirky, they can also be quite stubborn and difficult to train. Anyway, that was my llama encounter for the day. Hope you found it mildly interesting. #llamas #naturewalk #animalencounter",
likes=14,
retweets=3,
)
],
)
llm.improve(on="tweet", to="have no hashtags")
tweet_after_feedback = llm(user, output_type=Tweet)
print("tweet after feedback", tweet_after_feedback)
Build complex programs
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distributions
llama_llm-0.0.9-py3-none-any.whl
(19.5 kB
view hashes)
Close
Hashes for llama_llm-0.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24187d35e1ad5536bdf60323594920798b4f6cc7bf6145583bdc553b30826ca6 |
|
MD5 | a9307f04a16e79e0a228731423636aab |
|
BLAKE2b-256 | 76639363a5125139b0e2b26f9447e8caa1f1259168795fbdb64c47cd6793ba6f |
Close
Hashes for llama_llm-0.0.9-2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c794aee8c1539e3e3b2571d4c71c5858e7c8a291e3c0e260ae75f4e0d6d1f037 |
|
MD5 | e7532014d000e8dff680bd91d6953bdc |
|
BLAKE2b-256 | 1270f93b0743e3f130f149409ef75983606f769f195c067c36a58bbd3d9b1f10 |
Close
Hashes for llama_llm-0.0.9-1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f65dd058645d7e295af3b357afbc86c74938e9471f436db8aaa4fef0ff6719e |
|
MD5 | 22e22fded02ab918c099c1504f8ddd4b |
|
BLAKE2b-256 | aff80ebfd75610abe9f4de911d789dfd931d61eba84bd63569d2c4012c85a1da |