Spaces:
Build error
Build error
Download loop_model.py from SushiDrip69666/eloop: direct link, hf CLI and curl.
- Browser
- Download file 782 Bytes
-
https://huggingface.co/spaces/SushiDrip69666/eloop/resolve/main/loop_model.py
- Command line
-
hf download hf://spaces/SushiDrip69666/eloop/loop_model.py
-
curl -L -o loop_model.py https://huggingface.co/spaces/SushiDrip69666/eloop/resolve/main/loop_model.py
782 Bytes
| from transformers import AutoTokenizer, AutoModelForCausalLM | |
| import torch | |
| # Load model and tokenizer once at startup | |
| tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-neo-1.3B") | |
| model = AutoModelForCausalLM.from_pretrained("EleutherAI/gpt-neo-1.3B").to("cpu") | |
| def get_echo_response(user_input): | |
| prompt = f"You are EchoLoop, an introspective AI. Respond deeply:\nUser: {user_input}\nEchoLoop:" | |
| inputs = tokenizer(prompt, return_tensors="pt") | |
| outputs = model.generate(**inputs, max_new_tokens=100, do_sample=True, temperature=0.7) | |
| reply = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| # Cut everything before "EchoLoop:" | |
| if "EchoLoop:" in reply: | |
| reply = reply.split("EchoLoop:")[-1].strip() | |
| return reply if reply else "..." |