Skip to content

Instantly share code, notes, and snippets.

import humingbird
import random
intents = {
"greeting": ["Hi! Welcome to the ice cream shop.", "Welcome! What can i help you with?"],
"goodbye": ["Goodbye!", "Nice chatting! Have a great day."],
"menu": ["Here is our menu: https://www.randomicecream.co"],
"prices": ["Our prices our affordable for all!", "We have super low prices! Pracitcally free!"],
"start_order": ["Lets start the order here: https://www.fakepaymentlink.com"]
}
import humingbird
prediction = humingbird.Image.predict(
image_path='ice-cream.jpg',
labels=["strawberry ice cream", "vanilla ice cream", "chocolate ice cream"] # add more if you'd like :)
)
print(prediction)
import humingbird
import random
intents = {
"greeting": ["Hi! Welcome to the ice cream shop.", "Welcome! What can i help you with?"],
"goodbye": ["Goodbye!", "Nice chatting! Have a great day."],
"menu": ["Here is our menu: https://www.randomicecream.co"],
"prices": ["Our prices our affordable for all!", "We have super low prices! Pracitcally free!"],
"start_order": ["Lets start the order here: https://www.fakepaymentlink.com"]
}
{
"greetings": ["Hi! Welcome to the ice cream shop.", "Welcome! What can i help you with?"],
"goodbyes": ["Goodbye!", "Nice chatting! Have a great day."],
"menu": ["Here is our menu: https://www.randomicecream.co"],
"prices": ["Our prices our affordable for all!", "We have super low prices! Pracitcally free!"],
"start_order": ["Lets start the order here: https://www.fakepaymentlink.com"]
}
import humingbird
intent_recognition = humingbird.Text.predict(
text="I was wondering what you have on your menu? I love ice cream!",
labels=["greeting", "goodbye", "menu", "prices", "start_order"]
)
print(intent_recognition)
{
"generated_text": "I am building a Humingbird app for everyone at 12:00 am, but I do it for the people of the world ....",
"warning": "WARNING: This output may contain sensitive or toxic text. Please use with caution."
}
{
"prompt": "I am building a Humingbird app for everyone at 12:00 am, but I do it for the"
}
# import libraries
from flask import request, jsonify, Flask, abort
import transformers
from transformers import pipeline
import humingbird
# start flask app
app = Flask(__name__)
# download GPT-2/load the model
import transformers
from transformers import pipeline
import humingbird
# load the model
generator = pipeline('text-generation', model='gpt2')
# generate a sample
generation = (generator("I went for a walk today and saw a", max_length=60))[0]['generated_text']
import humingbird
content_filter = humingbird.Text.predict(
text="our sample text for Humingbird! This is so easy.",
labels=["toxic", "not toxic"]
)
print(content_filter)