Views
No views yet
| codegemma-2b | codegemma-7b | codegemma-7b-it | |
|---|---|---|---|
| Code Completion | ✅ | ✅ | |
| Generation from natural language | ✅ | ✅ | |
| Chat | ✅ | ||
| Instruction Following | ✅ |
1from transformers import GemmaTokenizer, AutoModelForCausalLM
2tokenizer = GemmaTokenizer.from_pretrained("EpistemeAI/Athene-codegemma-2-7b-it-alpaca-v1.2")
3model = AutoModelForCausalLM.from_pretrained("EpistemeAI/Athene-codegemma-2-7b-it-alpaca-v1.2")
4input_text = "Write me a Python function to calculate the nth fibonacci number."
5input_ids = tokenizer(input_text, return_tensors="pt")
6outputs = model.generate(**input_ids)
7print(tokenizer.decode(outputs[0]))1from transformers import AutoTokenizer, AutoModelForCausalLM
2import transformers
3import torch
4model_id = "EpistemeAI/Athene-codegemma-2-7b-it-alpaca-v1.2"
5dtype = torch.bfloat16
6tokenizer = AutoTokenizer.from_pretrained(model_id)
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 device_map="cuda",
10 torch_dtype=dtype,
11)
12chat = [
13 { "role": "user", "content": "Write a hello world program" },
14]
15prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)<bos><start_of_turn>user
Write a hello world program<end_of_turn>
<start_of_turn>model<start_of_turn> delimiter and then the role of the entity
(either user, for content supplied by the user, or model for LLM responses). Turns finish with
the <end_of_turn> token.1inputs = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
2outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=150)1import pygame
2import sys
3import time
4import random
5# Initialize Pygame
6pygame.init()
7# Set up some constants
8WIDTH = 800
9HEIGHT = 600
10BLOCK_SIZE = 20
11# Create the game screen
12screen = pygame.display.set_mode((WIDTH, HEIGHT))
13# Set up the colors
14BLACK = (0, 0, 0)
15WHITE = (255, 255, 255)
16RED = (255, 0, 0)
17GREEN = (0, 255, 0)
18# Set up the font
19font = pygame.font.Font(None, 36)
20# Set up the snake and food
21snake = [(200, 200), (220, 200), (240, 200)]
22food = (400, 300)
23# Set up the direction
24direction = 'RIGHT'
25# Game loop
26while True:
27 for event in pygame.event.get():
28 if event.type == pygame.QUIT:
29 pygame.quit()
30 sys.exit()
31 elif event.type == pygame.KEYDOWN:
32 if event.key == pygame.K_UP and direction!= 'DOWN':
33 direction = 'UP'
34 elif event.key == pygame.K_DOWN and direction!= 'UP':
35 direction = 'DOWN'
36 elif event.key == pygame.K_LEFT and direction!= 'RIGHT':
37 direction = 'LEFT'
38 elif event.key == pygame.K_RIGHT and direction!= 'LEFT':
39 direction = 'RIGHT'
40 # Move the snake
41 head = snake[-1]
42 if direction == 'UP':
43 new_head = (head[0], head[1] - BLOCK_SIZE)
44 elif direction == 'DOWN':
45 new_head = (head[0], head[1] + BLOCK_SIZE)
46 elif direction == 'LEFT':
47 new_head = (head[0] - BLOCK_SIZE, head[1])
48 elif direction == 'RIGHT':
49 new_head = (head[0] + BLOCK_SIZE, head[1])
50 snake.append(new_head)
51 # Check if the snake has eaten the food
52 if snake[-1] == food:
53 food = (random.randint(0, WIDTH - BLOCK_SIZE) // BLOCK_SIZE * BLOCK_SIZE,
54 random.randint(0, HEIGHT - BLOCK_SIZE) // BLOCK_SIZE * BLOCK_SIZE)
55 else:
56 snake.pop(0)
57 # Check if the snake has collided with the edge or itself
58 if (snake[-1][0] < 0 or snake[-1][0] >= WIDTH or
59 snake[-1][1] < 0 or snake[-1][1] >= HEIGHT or
60 snake[-1] in snake[:-1]):
61 print("Game Over!")
62 time.sleep(2)
63 break
64 # Draw the game screen
65 screen.fill(BLACK)
66 for pos in snake:
67 pygame.draw.rect(screen, GREEN, (pos[0], pos[1], BLOCK_SIZE, BLOCK_SIZE))
68 pygame.draw.rect(screen, RED, (food[0], food[1], BLOCK_SIZE, BLOCK_SIZE))
69 text = font.render(f'Score: {len(snake) - 3}', True, WHITE)
70 screen.blit(text, (10, 10))
71 pygame.display.flip()
72 # Cap the frame rate
73 pygame.time.Clock().tick(10)