Views
No views yet
1import requests
2
3API_URL = "https://api-inference.huggingface.co/models/YOUR_USERNAME/phi3-sustainable-materials"
4headers = {"Authorization": "Bearer YOUR_HF_TOKEN"}
5
6def classify_material(product_name):
7 prompt = f"""Below is product data. Classify the sustainable material.
8
9### Input:
10Product: {product_name}
11
12### Response:
13"""
14
15 response = requests.post(API_URL, headers=headers, json={
16 "inputs": prompt,
17 "parameters": {
18 "max_new_tokens": 256,
19 "temperature": 0.7,
20 "return_full_text": False
21 }
22 })
23 return response.json()
24
25# Example
26result = classify_material("Recycled Cardboard Notebook")
27print(result)1{
2 "material_name": "Recycled Cardboard",
3 "reason": "Product explicitly mentions recycled cardboard material",
4 "confidence": "100% confident",
5 "confidence_level": "high"
6}@misc{phi3-sustainable-materials,
author = {Your Name},
title = {Phi-3 Sustainable Materials Classifier},
year = {2026},
publisher = {HuggingFace},
url = {https://huggingface.co/YOUR_USERNAME/phi3-sustainable-materials}
}