Download app from badru/mms10: direct link, hf CLI and curl.
- Browser
- Download file 1.34 kB
-
https://huggingface.co/spaces/badru/mms10/resolve/main/app
- Command line
-
hf download hf://spaces/badru/mms10/app
-
curl -L -o app https://huggingface.co/spaces/badru/mms10/resolve/main/app
1.34 kB
| # This is a basic Hugging Face Space using Gradio to beautify and complete sentences. | |
| # You can deploy this in your Space (https://huggingface.co/spaces) | |
| import gradio as gr | |
| from transformers import pipeline | |
| # Load a free instruction-following model | |
| pipe = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.1", device_map="auto") | |
| def complete_sentence(input_text): | |
| if not input_text.strip(): | |
| return "No input provided." | |
| prompt = f"Beautify and complete the following sentence: | |
| @@@{input_text}###" | |
| try: | |
| output = pipe(prompt, max_new_tokens=100, do_sample=True, temperature=0.7) | |
| generated = output[0]['generated_text'] | |
| # Extract text between markers | |
| start = generated.find("@@@") | |
| end = generated.find("###", start) | |
| if start != -1 and end != -1: | |
| beautified = generated[start+3:end].strip() | |
| return beautified | |
| else: | |
| return generated.strip() | |
| except Exception as e: | |
| return f"Error: {str(e)}" | |
| iface = gr.Interface( | |
| fn=complete_sentence, | |
| inputs=gr.Textbox(label="Enter your sentence"), | |
| outputs=gr.Textbox(label="Completed sentence"), | |
| title="Sentence Beautifier (Mistral 7B)", | |
| description="Enter a raw or incomplete sentence. The AI will beautify and complete it." | |
| ) | |
| iface.launch() | |