Instructions to use rombodawg/Llama-3-8B-Instruct-Coder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use rombodawg/Llama-3-8B-Instruct-Coder with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="rombodawg/Llama-3-8B-Instruct-Coder") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("rombodawg/Llama-3-8B-Instruct-Coder") model = AutoModelForCausalLM.from_pretrained("rombodawg/Llama-3-8B-Instruct-Coder") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use rombodawg/Llama-3-8B-Instruct-Coder with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "rombodawg/Llama-3-8B-Instruct-Coder" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rombodawg/Llama-3-8B-Instruct-Coder", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/rombodawg/Llama-3-8B-Instruct-Coder
- SGLang
How to use rombodawg/Llama-3-8B-Instruct-Coder with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "rombodawg/Llama-3-8B-Instruct-Coder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rombodawg/Llama-3-8B-Instruct-Coder", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
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 "rombodawg/Llama-3-8B-Instruct-Coder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rombodawg/Llama-3-8B-Instruct-Coder", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio new
How to use rombodawg/Llama-3-8B-Instruct-Coder with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for rombodawg/Llama-3-8B-Instruct-Coder to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for rombodawg/Llama-3-8B-Instruct-Coder to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for rombodawg/Llama-3-8B-Instruct-Coder to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="rombodawg/Llama-3-8B-Instruct-Coder", max_seq_length=2048, ) - Docker Model Runner
How to use rombodawg/Llama-3-8B-Instruct-Coder with Docker Model Runner:
docker model run hf.co/rombodawg/Llama-3-8B-Instruct-Coder
Passes "snake in python test" after only 3 attempts
After 3 diffrent attempts (the first 3 being failures) it made a perfect game of snake. And it was even able to itterate on the code an add aditional features. Originally this code only had a snake and no food, it added the food the second prompt.
To test this code save the file in a word document, name it "snake.py", open command prompt where that file is saved, and then run "python snake.py".
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Set up some constants
WIDTH, HEIGHT = 800, 600
SPEED = 10
BLOCK_SIZE = 20
WHITE = (255, 255, 255)
RED = (255, 0, 0)
# Set up the display
screen = pygame.display.set_mode((WIDTH, HEIGHT))
# Set up the snake and food
snake = [(200, 200), (220, 200), (240, 200)]
food = None
direction = 'right'
# Function to draw the snake and food
def draw_snake_and_food(snake, food):
screen.fill(WHITE)
for pos in snake:
pygame.draw.rect(screen, RED, (pos[0], pos[1], BLOCK_SIZE, BLOCK_SIZE))
if food:
pygame.draw.rect(screen, (0, 255, 0), (food[0], food[1], BLOCK_SIZE, BLOCK_SIZE))
# Game loop
while True:
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP and direction!= 'down':
direction = 'up'
elif event.key == pygame.K_DOWN and direction!= 'up':
direction = 'down'
elif event.key == pygame.K_LEFT and direction!= 'right':
direction = 'left'
elif event.key == pygame.K_RIGHT and direction!= 'left':
direction = 'right'
# Move the snake
head = snake[-1]
if direction == 'up':
new_head = (head[0], max(0, head[1] - BLOCK_SIZE))
elif direction == 'down':
new_head = (head[0], min(HEIGHT - BLOCK_SIZE, head[1] + BLOCK_SIZE))
elif direction == 'left':
new_head = (max(0, head[0] - BLOCK_SIZE), head[1])
else:
new_head = (min(WIDTH - BLOCK_SIZE, head[0] + BLOCK_SIZE), head[1])
snake.append(new_head)
# Check for collision with self or wall
if new_head in snake[:-1]:
print("Game Over")
pygame.quit()
sys.exit()
elif not (0 <= new_head[0] < WIDTH and 0 <= new_head[1] < HEIGHT):
print("Game Over")
pygame.quit()
sys.exit()
# Check for food consumption
if new_head == food:
food = None
else:
snake.pop(0)
# Generate new food if none exists
if not food:
food = (random.randint(0, WIDTH - BLOCK_SIZE) // BLOCK_SIZE * BLOCK_SIZE,
random.randint(0, HEIGHT - BLOCK_SIZE) // BLOCK_SIZE * BLOCK_SIZE)
# Draw everything
draw_snake_and_food(snake, food)
pygame.display.flip()
# Cap the frame rate
pygame.time.delay(1000 // SPEED)
Here is another one i had it do of pong instead of snake
import pygame
import sys
import random
# Initialize Pygame
pygame.init()
# Set up some constants
WIDTH, HEIGHT = 640, 480
BALL_RADIUS = 10
PADDLE_WIDTH, PADDLE_HEIGHT = 10, 60
FPS = 60
# Create the game window
screen = pygame.display.set_mode((WIDTH, HEIGHT))
# Set up the title of the window
pygame.display.set_caption("Pong")
# Define some colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
# Set up the ball and paddles
ball_x, ball_y = random.randint(0, WIDTH - BALL_RADIUS) + BALL_RADIUS, random.randint(0, HEIGHT - BALL_RADIUS) + BALL_RADIUS
ball_vx, ball_vy = 5, -5
paddle1_y, paddle2_y = HEIGHT // 2, HEIGHT // 2
score1, score2 = 0, 0
# Font for displaying scores
font = pygame.font.Font(None, 36)
# Game loop
while True:
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_w:
paddle1_y -= 5
elif event.key == pygame.K_s:
paddle1_y += 5
elif event.key == pygame.K_UP:
paddle2_y -= 5
elif event.key == pygame.K_DOWN:
paddle2_y += 5
# Move the paddles
keys = pygame.key.get_pressed()
if keys[pygame.K_w]:
paddle1_y -= 5
if keys[pygame.K_s]:
paddle1_y += 5
if keys[pygame.K_UP]:
paddle2_y -= 5
if keys[pygame.K_DOWN]:
paddle2_y += 5
# Move the ball
ball_x += ball_vx
ball_y += ball_vy
# Collision with walls
if ball_y < BALL_RADIUS or ball_y > HEIGHT - BALL_RADIUS:
ball_vy *= -1
if ball_x < BALL_RADIUS or ball_x > WIDTH - BALL_RADIUS:
ball_vx *= -1
# Collision with paddles
if ball_x < PADDLE_WIDTH + BALL_RADIUS and paddle1_y < ball_y < paddle1_y + PADDLE_HEIGHT:
ball_vx *= -1
if ball_x > WIDTH - PADDLE_WIDTH - BALL_RADIUS and paddle2_y < ball_y < paddle2_y + PADDLE_HEIGHT:
ball_vx *= -1
# Check for goals
if ball_x < BALL_RADIUS:
score2 += 1
ball_x, ball_y = random.randint(0, WIDTH - BALL_RADIUS) + BALL_RADIUS, random.randint(0, HEIGHT - BALL_RADIUS) + BALL_RADIUS
ball_vx, ball_vy = 5, -5
elif ball_x > WIDTH - BALL_RADIUS:
score1 += 1
ball_x, ball_y = random.randint(0, WIDTH - BALL_RADIUS) + BALL_RADIUS, random.randint(0, HEIGHT - BALL_RADIUS) + BALL_RADIUS
ball_vx, ball_vy = 5, -5
# Draw everything
screen.fill(BLACK)
pygame.draw.rect(screen, WHITE, (0, paddle1_y, PADDLE_WIDTH, PADDLE_HEIGHT))
pygame.draw.rect(screen, WHITE, (WIDTH - PADDLE_WIDTH, paddle2_y, PADDLE_WIDTH, PADDLE_HEIGHT))
pygame.draw.circle(screen, WHITE, (int(ball_x), int(ball_y)), BALL_RADIUS)
# Display scores
text_surface = font.render(f"{score1} - {score2}", True, WHITE)
screen.blit(text_surface, (WIDTH // 4, 20))
# Update the display
pygame.display.flip()
pygame.time.Clock().tick(FPS)
But what's the point, when standard llama3 can do that too?