YAML Metadata
Warning:
empty or missing yaml metadata in repo card
(https://huggingface.co/docs/hub/model-cards#model-card-metadata)
Moroccan Tourism Chatbot
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.
Usage
!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()
- Downloads last month
- 109
Inference Providers
NEW
This model is not currently available via any of the supported third-party Inference Providers, and
HF Inference API was unable to determine this model's library.