Spaces:
Paused
Paused
from transformers import AutoModelForCausalLM, AutoTokenizer | |
food = ["Cheese dip with chili pepper", | |
"Pepperoni, NFS", | |
"Pepperoni, reduced fat", | |
"Pepperoni, reduced sodium", | |
"Stuffed green pepper, Puerto Rican style", | |
"Pepper steak", | |
"Sausage and peppers, no sauce", | |
"Pepperpot soup", | |
"Pizza with pepperoni, from frozen, thin crust", | |
"Pizza with pepperoni, from frozen, medium crust", | |
"Pizza with pepperoni, from frozen, thick crust", | |
"Pizza with pepperoni, from restaurant or fast food, NS as to type of crust", | |
"Pizza with pepperoni, from restaurant or fast food, thin crust", | |
"Pizza with pepperoni, from restaurant or fast food, medium crust", | |
"Pizza with pepperoni, from restaurant or fast food, thick crust", | |
"Pizza with pepperoni, stuffed crust", | |
"Pizza with pepperoni, from school lunch, thin crust", | |
"Pizza, with pepperoni, from school lunch, medium crust", | |
"Pizza with pepperoni, from school lunch, thick crust", | |
"Pizza with meat other than pepperoni, from frozen, thin crust", | |
"Pizza with meat other than pepperoni, from frozen, medium crust", | |
"Pizza with meat other than pepperoni, from frozen, thick crust", | |
"Pizza with meat other than pepperoni, from restaurant or fast food, NS as to type of crust", | |
"Pizza with meat other than pepperoni, from restaurant or fast food, thin crust", | |
"Pizza with meat other than pepperoni, from restaurant or fast food, medium crust", | |
"Pizza with meat other than pepperoni, from restaurant or fast food, thick crust", | |
"Pizza, with meat other than pepperoni, stuffed crust", | |
"Pizza, with meat other than pepperoni, from school lunch, medium crust", | |
"Pizza, with meat other than pepperoni, from school lunch, thin crust", | |
"Pizza, with meat other than pepperoni, from school lunch, thick crust", | |
"Stuffed pepper, with meat", | |
"Stuffed pepper, with rice and meat", | |
"Stuffed pepper, with rice, meatless", | |
"Pepper, hot chili, raw", | |
"Pepper, raw, NFS", | |
"Pepper, sweet, green, raw", | |
"Pepper, sweet, red, raw", | |
"Pepper, banana, raw", | |
"Seven-layer salad, lettuce salad made with a combination of onion, celery, green pepper, peas, mayonnaise, cheese, eggs, and/or bacon", | |
"Peppers, green, cooked", | |
"Peppers, red, cooked", | |
"Hot peppers, cooked", | |
"Peppers and onions, cooked, no added fat", | |
"Peppers and onions, cooked, fat added", | |
"Stuffed jalapeno pepper", | |
"Hot pepper sauce", | |
"Peppers, pickled", | |
"Pepper, hot, pickled", | |
"Pepper, for use on a sandwich", | |
"Soft drink, pepper type", | |
"Soft drink, pepper type, diet", | |
"Soft drink, pepper type, decaffeinated", | |
"Soft drink, pepper type, decaffeinated, diet", | |
"Green pepper, cooked, as ingredient", | |
"Red pepper, cooked, as ingredient", | |
"Pepperidge Farm, Goldfish, Baked Snack Crackers, Original", | |
"Pepperidge Farm, Goldfish, Baked Snack Crackers, Parmesan", | |
"Pepperidge Farm, Goldfish, Baked Snack Crackers, Pizza", | |
"Candies, YORK Peppermint Pattie", | |
"Pepperidge Farm, Goldfish, Baked Snack Crackers, Cheddar", | |
"Pepperidge Farm, Goldfish, Baked Snack Crackers, Explosive Pizza", | |
"Salad dressing, peppercorn dressing, commercial, regular", | |
"HORMEL ALWAYS TENDER, Pork Tenderloin, Peppercorn-Flavored", | |
"Peppers, sweet, red, canned, solids and liquids", | |
"Peppers, sweet, red, frozen, chopped, unprepared", | |
"Peppers, sweet, red, frozen, chopped, boiled, drained, without salt", | |
"Peppers, sweet, red, frozen, chopped, boiled, drained, with salt", | |
"Peppers, sweet, red, sauteed", | |
"Peppers, hot chile, sun-dried", | |
"Peppers, jalapeno, raw", | |
"Peppers, chili, green, canned", | |
"Peppers, hungarian, raw", | |
"Peppers, pasilla, dried", | |
"Corn with red and green peppers, canned, solids and liquids", | |
"Peppers, sweet, red, freeze-dried", | |
"Peppers, sweet, yellow, raw", | |
"Peppers, serrano, raw", | |
"Peppers, ancho, dried", | |
"Peppers, hot pickled, canned", | |
"Peppers, sweet, green, frozen, chopped, unprepared", | |
"Peppers, sweet, green, frozen, chopped, boiled, drained, without salt", | |
"Peppers, sweet, green, sauteed", | |
"Peppers, jalapeno, canned, solids and liquids", | |
"Peppers, hot chili, red, raw", | |
"Peppers, hot chili, red, canned, excluding seeds, solids and liquids", | |
"Peppers, sweet, red, raw", | |
"Peppers, sweet, green, cooked, boiled, drained, with salt", | |
"Peppers, sweet, red, cooked, boiled, drained, without salt", | |
"PIZZA HUT 14' Pepperoni Pizza, THIN 'N CRISPY Crust", | |
"DOMINO'S 14' Pepperoni Pizza, Crunchy Thin Crust", | |
"Peppers, hot chili, green, canned, pods, excluding seeds, solids and liquids", | |
"Peppers, sweet, green, raw", | |
"Peppers, sweet, green, cooked, boiled, drained, without salt", | |
"Peppers, sweet, green, canned, solids and liquids", | |
"Tomato products, canned, sauce, with onions, green peppers, and celery", | |
"Peppers, hot chili, green, raw", | |
"Peppers, sweet, red, cooked, boiled, drained, with salt", | |
"Peppers, sweet, green, frozen, chopped, cooked, boiled, drained, with salt", | |
"School Lunch, pizza, BIG DADDY'S LS 16' 51% Whole Grain Rolled Edge Turkey Pepperoni Pizza, frozen", | |
"School Lunch, pizza, TONY'S SMARTPIZZA Whole Grain 4x6 Pepperoni Pizza 50/50 Cheese, frozen", | |
"DIGIORNO Pizza, pepperoni topping, cheese stuffed crust, frozen, baked", | |
"DIGIORNO Pizza, pepperoni topping, rising crust, frozen, baked", | |
"DIGIORNO Pizza, pepperoni topping, thin crispy crust, frozen, baked", | |
"Fast Food, Pizza Chain, 14' pizza, pepperoni topping, thin crust", | |
"School Lunch, pizza, pepperoni topping, thin crust, whole grain, frozen, cooked", | |
"School Lunch, pizza, pepperoni topping, thick crust, whole grain, frozen, cooked", | |
"Spices, pepper, black", | |
"Spices, pepper, red or cayenne", | |
"Spices, pepper, white", | |
"Sauce, peppers, hot, chili, mature red, canned", | |
"Sauce, chili, peppers, hot, immature green, canned", | |
"Beverages, carbonated, low calorie, cola or pepper-types, with sodium saccharin, contains caffeine", | |
"DOMINO'S 14' Pepperoni Pizza, Classic Hand-Tossed Crust", | |
"DOMINO'S 14' Pepperoni Pizza, Ultimate Deep Dish Crust", | |
"LITTLE CAESARS 14' Original Round Pepperoni Pizza, Regular Crust", | |
"PIZZA HUT 14' Pepperoni Pizza, Hand-Tossed Crust", | |
"PIZZA HUT 14' Pepperoni Pizza, Pan Crust", | |
"Pizza, pepperoni topping, regular crust, frozen, cooked", | |
"Beverages, carbonated, low calorie, other than cola or pepper, without caffeine", | |
"Beverages, carbonated, low calorie, other than cola or pepper, with aspartame, contains caffeine", | |
"Beverages, carbonated, pepper-type, contains caffeine", | |
"PIZZA HUT 12' Pepperoni Pizza, Hand-Tossed Crust", | |
"PIZZA HUT 12' Pepperoni Pizza, Pan Crust", | |
"PAPA JOHN'S 14' Pepperoni Pizza, Original Crust", | |
"LITTLE CAESARS 14' Pepperoni Pizza, Large Deep Dish Crust", | |
"Fast Food, Pizza Chain, 14' pizza, pepperoni topping, regular crust", | |
"Fast Food, Pizza Chain, 14' pizza, pepperoni topping, thick crust", | |
"Peppermint, fresh", | |
"Sauce, ready-to-serve, pepper or hot", | |
"Sauce, ready-to-serve, pepper, TABASCO", | |
"Peppered loaf, pork, beef", | |
"Pepperoni, beef and pork, sliced", | |
"Hormel Pillow Pak Sliced Turkey Pepperoni", | |
"Turkey, breast, smoked, lemon pepper flavor, 97% fat-free", | |
"Beverages, carbonated, low calorie, cola or pepper-type, with aspartame, without caffeine", | |
"Beverages, carbonated, low calorie, cola or pepper-type, with aspartame, contains caffeine", | |
"Carbonated beverage, low calorie, other than cola or pepper, with sodium saccharin, without caffeine", | |
"NFY0907NU", | |
"NFY0907N6", | |
"NFY0907OU", | |
"OATMEAL COOKIES WITH RAISINS, PEPPERIDGE FARM SOFT BAKED", | |
"Peppers, bell, green, raw", | |
"Peppers, bell, yellow, raw", | |
"Peppers, bell, red, raw", | |
"Peppers, bell, orange, raw", | |
"peppers, bell, green, raw", | |
"peppers, bell, red, raw", | |
"peppers, bell, yellow, raw", | |
"peppers, bell, orange, raw", | |
"peppers, bell, red, raw, mini ", | |
"peppers, bell, orange, raw, mini "] | |
# Load the tokenizer and model from Hugging Face | |
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3-8B-instruct") | |
model = AutoModelForCausalLM.from_pretrained("meta-llama/Meta-Llama-3-8B-instruct") | |
# Define the input message | |
input_text = "Return the name in a short JSON object. What item from this list is most similar to: 'Pepper - Habanero Pepper'. List: " + "; ".join(food) | |
# Tokenize the input | |
inputs = tokenizer(input_text, return_tensors="pt") | |
# Generate the response | |
outputs = model.generate(inputs["input_ids"], max_new_tokens=50, pad_token_id=tokenizer.eos_token_id) | |
# Decode the output | |
response = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
print(response) | |