Downloads · 30 days
4
15% of all-time downloads
aboutaleb/llama-3-8b-chat-tourismneweeest
llama-3-8b-chat-tourismneweeest is a machine learning model from aboutaleb. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This is a fine-tuned version of Llama-3.1 designed to assist tourists in Morocco by providing recommendations for hotels, beaches, restaurants, and activities based on user queries.
Downloads · 30 days
4
15% of all-time downloads
All-time downloads
26
Public
Parameters
8.1B
6 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors6 GB · 100%
How the weights are stored.
U87B · 86%
From the Hugging Face model README
This is a fine-tuned version of Llama-3.1 designed to assist tourists in Morocco by providing recommendations for hotels, beaches, restaurants, and activities based on user queries.
!pip install gradio
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("aboutaleb/llama-3-8b-chat-tourismneweeest")
tokenizer = AutoTokenizer.from_pretrained("aboutaleb/llama-3-8b-chat-tourismneweeest")
def get_recommendations(user_query):
"""
Function to generate tourism recommendations based on user input.
"""
# Preprocessing: remove unwanted characters (e.g., </)
cleaned_query = user_query.replace('</', '').replace('>', '')
# Format input text with instructions
input_text = f"""Below is a user query about tourism in Morocco. Provide concise and accurate recommendations:
### User Query:
{cleaned_query}
### Recommendations:
"""
# Tokenization and generation
inputs = tokenizer([input_text], return_tensors="pt", truncation=True).to("cuda")
outputs = model.generate(**inputs, max_new_tokens=100)
# Decode the response and clean unnecessary tags
recommendations = tokenizer.decode(outputs[0], skip_special_tokens=True)
# Clean additional tokens (</s> or others)
recommendations = recommendations.replace('</s>', '').strip()
# Return only the recommendations section
if "### Recommendations:" in recommendations:
recommendations = recommendations.split("### Recommendations:")[1].strip()
return recommendations
# Gradio Interface
with gr.Blocks() as demo:
gr.Markdown("## Moroccan Tourism Assistant")
gr.Markdown(
"Enter your query about tourism in Morocco below. "
"You will receive recommendations for hotels, beaches, restaurants, or activities."
)
with gr.Row():
input_box = gr.Textbox(
label="User Query",
placeholder="Enter your question about tourism in Morocco here...",
lines=5
)
output_box = gr.Textbox(
label="Generated Recommendations",
placeholder="Recommendations will appear here...",
lines=5
)
generate_button = gr.Button("Get Recommendations")
generate_button.click(get_recommendations, inputs=input_box, outputs=output_box)
# Launch the application
demo.launch()