alxxtexxr/IndoWebGen-Data
Viewer • Updated • 500 • 17
How to use alxxtexxr/IndoWebGen-7B with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="alxxtexxr/IndoWebGen-7B") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("alxxtexxr/IndoWebGen-7B")
model = AutoModelForCausalLM.from_pretrained("alxxtexxr/IndoWebGen-7B")How to use alxxtexxr/IndoWebGen-7B with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "alxxtexxr/IndoWebGen-7B"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "alxxtexxr/IndoWebGen-7B",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/alxxtexxr/IndoWebGen-7B
How to use alxxtexxr/IndoWebGen-7B with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "alxxtexxr/IndoWebGen-7B" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "alxxtexxr/IndoWebGen-7B",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "alxxtexxr/IndoWebGen-7B" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "alxxtexxr/IndoWebGen-7B",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use alxxtexxr/IndoWebGen-7B with Docker Model Runner:
docker model run hf.co/alxxtexxr/IndoWebGen-7B
Hugely inspired by Web App Factory.
Try running the inference code with the provided Google Colab notebook here. The inference code used is shown below:
# Install the required libraries
!pip install transformers bitsandbytes accelerate
# Import the neccessary modules
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load the model and the tokenizer
model_id = 'alxxtexxr/indowebgen-7b'
model = AutoModelForCausalLM.from_pretrained(
model_id,
load_in_8bit=True,
# load_in_4bit=True, # for low memory
device_map='auto',
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
# Initialize the prompt
prompt_template = '''Berikut adalah instruksi pembuatan website beserta output-nya yang berupa kode HTML dari website yang dibuat:
### Instruksi:
{instruction}
### Output:
<!DOCTYPE html>
<html lang="id">'''
# INSERT YOUR OWN INDONESIAN INSTRUCTION BELOW
instruction = 'Buatlah website portfolio untuk Budi'
prompt = prompt_template.format(instruction=instruction)
# Generate the output
input_ids = tokenizer(prompt, return_tensors='pt').input_ids.to(model.device)
outputs = model.generate(
input_ids,
max_new_tokens=2400,
do_sample=True,
temperature=1.0,
top_k=3,
top_p=0.8,
repetition_penalty=1.1,
pad_token_id=tokenizer.unk_token_id,
)
print(tokenizer.batch_decode(outputs, skip_special_tokens=True)[0])