Text Generation
Transformers
Safetensors
llama
conversational
text-generation-inference
Inference Endpoints

AMAZING CODING MODEL!!!

#1
by rombodawg - opened

OMG this model is amazing look at this code its perfect!!! It wrote the games of snake perfectly first try. Its as good as gpt 3.5 maybe better at coding!!!

This is the verison i used
TheBloke/Magicoder-S-DS-6.7B-GPTQ
gptq-8bit--1g-actorder_True

Here is the code the model wrote, try running it yourself its flawless, and it wrote it the first time, no need to fix anything,:

import turtle
import time
import random

delay = 0.1
score = 0
high_score = 0

# Set up screen
wn = turtle.Screen()
wn.title("Snake by @TokyoEdTech")  # Change title as per your preference
wn.bgcolor("green")                # Change background color if needed
wn.setup(width=600, height=600)     # Size of window
wn.tracer(0)                       # Turn off automatic animation on screen updates

# Snake head
head = turtle.Turtle()
head.speed(0)                      # Animation speed set to max possible speed (fastest)
head.shape("square")               # Shape of our object will be square
head.color("black")                 # Color of our object will be black
head.penup()                        # Penup function prevents drawing line while moving
head.goto(0, 0)                     # Initial position of snake at center of screen
head.direction = "stop"            # Default direction of movement when no key pressed

segments = []

# Food
food = turtle.Turtle()
food.speed(0)
food.shape("circle")              # Circular shape food item
food.color("red")                  # Red colour for food
food.penup()
food.goto(0, 100)                   # Positioning food initially above the screen

# Score board
pen = turtle.Turtle()
pen.speed(0)
pen.shape("square")
pen.color("white")
pen.penup()
pen.hideturtle()
pen.goto(0, 260)                    # Placing scoreboard below the screen
pen.write("Score : 0 High Score : 0", align="center", font=("Courier", 24, "normal"))

def go_up():
    if head.direction != "down":   # If we are not currently facing downwards then change heading towards upward
        head.direction = "up"

def go_down():
    if head.direction != "up":      # Same logic applies here but this time checking against opposite direction
        head.direction = "down"

def go_left():
    if head.direction != "right":
        head.direction = "left"

def go_right():
    if head.direction != "left":
        head.direction = "right"

def move():
    if head.direction == "up":       # Movement based on current direction faced
        y = head.ycor()
        head.sety(y + 20)

    elif head.direction == "down":
        y = head.ycor()
        head.sety(y - 20)

    elif head.direction == "left":
        x = head.xcor()
        head.setx(x - 20)

    else:                             # This means that direction must have been right so increment X coordinate
        x = head.xcor()
        head.setx(x + 20)

# Keyboard bindings
wn.listen()                          # Listen for keyboard input from player
wn.onkeypress(go_up, "w")           # When 'W' key is pressed call go_up method
wn.onkeypress(go_down, "s")          # When 'S' key is pressed call go_down method
wn.onkeypress(go_left, "a")          # When 'A' key is pressed call go_left method
wn.onkeypress(go_right, "d")         # When 'D' key is pressed call go_right method

while True:                           # Main loop which runs until break statement encountered or error occurs
    wn.update()                       # Update the screen everytime loop iterates

    # Check collision between head & body segments
    for segment in segments:
        if segment.distance(head) < 20:
            time.sleep(1)
            head.goto(0, 0)
            head.direction = "stop"

            # Hide all segments before resetting them
            for seg in segments:
                seg.goto(1000, 1000)

            # Clear list of segments
            segments = []

            # Reset score
            score = 0

            pen.clear()
            pen.write("Score : {} High Score : {}".format(score, high_score), align="center", font=("Courier", 24, "normal"))

    # Check for boundary collisions
    if head.xcor() > 290 or head.xcor() < -290 or head.ycor() > 290 or head.ycor() < -290:
        time.sleep(1)
        head.goto(0, 0)
        head.direction = "stop"

        # Hide all segments before resetting them
        for seg in segments:
            seg.goto(1000, 1000)

        # Clear list of segments
        segments = []

        # Reset score
        score = 0

        pen.clear()
        pen.write("Score : {} High Score : {}".format(score, high_score), align="center", font=("Courier", 24, "normal"))

    # Check for eating food
    if head.distance(food) < 20:
        # Move food to new location randomly within boundaries
        x = random.randint(-280, 280)
        y = random.randint(-280, 280)
        food.goto(x, y)

        # Add a new segment
        new_segment = turtle.Turtle()
        new_segment.speed(0)
        new_segment.shape("square")
        new_segment.color("grey")
        new_segment.penup()
        segments.append(new_segment)

        delay -= 0.001

        # Increase score
        score += 10

        if score > high_score:
            high_score = score

        pen.clear()
        pen.write("Score : {} High Score : {}".format(score, high_score), align="center", font=("Courier", 24, "normal"))

    # Move end segments first in reverse order
    for index in range(len(segments)-1, 0, -1):
        x = segments[index-1].xcor()
        y = segments[index-1].ycor()
        segments[index].goto(x, y)

    # Move segment zero to where the head was
    if len(segments) > 0:
        x = head.xcor()
        y = head.ycor()
        segments[0].goto(x, y)

    move()

    # Delay after each iteration
    time.sleep(delay)

turtle.done()

OMG this model is amazing look at this code its perfect!!! It wrote the games of snake perfectly first try. Its as good as gpt 3.5 maybe better at coding!!!

This is the verison i used
TheBloke/Magicoder-S-DS-6.7B-GPTQ
gptq-8bit--1g-actorder_True

Here is the code the model wrote, try running it yourself its flawless, and it wrote it the first time, no need to fix anything,:

import turtle
import time
import random

delay = 0.1
score = 0
high_score = 0

# Set up screen
wn = turtle.Screen()
wn.title("Snake by @TokyoEdTech")  # Change title as per your preference
wn.bgcolor("green")                # Change background color if needed
wn.setup(width=600, height=600)     # Size of window
wn.tracer(0)                       # Turn off automatic animation on screen updates

# Snake head
head = turtle.Turtle()
head.speed(0)                      # Animation speed set to max possible speed (fastest)
head.shape("square")               # Shape of our object will be square
head.color("black")                 # Color of our object will be black
head.penup()                        # Penup function prevents drawing line while moving
head.goto(0, 0)                     # Initial position of snake at center of screen
head.direction = "stop"            # Default direction of movement when no key pressed

segments = []

# Food
food = turtle.Turtle()
food.speed(0)
food.shape("circle")              # Circular shape food item
food.color("red")                  # Red colour for food
food.penup()
food.goto(0, 100)                   # Positioning food initially above the screen

# Score board
pen = turtle.Turtle()
pen.speed(0)
pen.shape("square")
pen.color("white")
pen.penup()
pen.hideturtle()
pen.goto(0, 260)                    # Placing scoreboard below the screen
pen.write("Score : 0 High Score : 0", align="center", font=("Courier", 24, "normal"))

def go_up():
    if head.direction != "down":   # If we are not currently facing downwards then change heading towards upward
        head.direction = "up"

def go_down():
    if head.direction != "up":      # Same logic applies here but this time checking against opposite direction
        head.direction = "down"

def go_left():
    if head.direction != "right":
        head.direction = "left"

def go_right():
    if head.direction != "left":
        head.direction = "right"

def move():
    if head.direction == "up":       # Movement based on current direction faced
        y = head.ycor()
        head.sety(y + 20)

    elif head.direction == "down":
        y = head.ycor()
        head.sety(y - 20)

    elif head.direction == "left":
        x = head.xcor()
        head.setx(x - 20)

    else:                             # This means that direction must have been right so increment X coordinate
        x = head.xcor()
        head.setx(x + 20)

# Keyboard bindings
wn.listen()                          # Listen for keyboard input from player
wn.onkeypress(go_up, "w")           # When 'W' key is pressed call go_up method
wn.onkeypress(go_down, "s")          # When 'S' key is pressed call go_down method
wn.onkeypress(go_left, "a")          # When 'A' key is pressed call go_left method
wn.onkeypress(go_right, "d")         # When 'D' key is pressed call go_right method

while True:                           # Main loop which runs until break statement encountered or error occurs
    wn.update()                       # Update the screen everytime loop iterates

    # Check collision between head & body segments
    for segment in segments:
        if segment.distance(head) < 20:
            time.sleep(1)
            head.goto(0, 0)
            head.direction = "stop"

            # Hide all segments before resetting them
            for seg in segments:
                seg.goto(1000, 1000)

            # Clear list of segments
            segments = []

            # Reset score
            score = 0

            pen.clear()
            pen.write("Score : {} High Score : {}".format(score, high_score), align="center", font=("Courier", 24, "normal"))

    # Check for boundary collisions
    if head.xcor() > 290 or head.xcor() < -290 or head.ycor() > 290 or head.ycor() < -290:
        time.sleep(1)
        head.goto(0, 0)
        head.direction = "stop"

        # Hide all segments before resetting them
        for seg in segments:
            seg.goto(1000, 1000)

        # Clear list of segments
        segments = []

        # Reset score
        score = 0

        pen.clear()
        pen.write("Score : {} High Score : {}".format(score, high_score), align="center", font=("Courier", 24, "normal"))

    # Check for eating food
    if head.distance(food) < 20:
        # Move food to new location randomly within boundaries
        x = random.randint(-280, 280)
        y = random.randint(-280, 280)
        food.goto(x, y)

        # Add a new segment
        new_segment = turtle.Turtle()
        new_segment.speed(0)
        new_segment.shape("square")
        new_segment.color("grey")
        new_segment.penup()
        segments.append(new_segment)

        delay -= 0.001

        # Increase score
        score += 10

        if score > high_score:
            high_score = score

        pen.clear()
        pen.write("Score : {} High Score : {}".format(score, high_score), align="center", font=("Courier", 24, "normal"))

    # Move end segments first in reverse order
    for index in range(len(segments)-1, 0, -1):
        x = segments[index-1].xcor()
        y = segments[index-1].ycor()
        segments[index].goto(x, y)

    # Move segment zero to where the head was
    if len(segments) > 0:
        x = head.xcor()
        y = head.ycor()
        segments[0].goto(x, y)

    move()

    # Delay after each iteration
    time.sleep(delay)

turtle.done()

How did you inference the model (did you write a python code? Or did you use the various model loaders?)what platform are you on and what are the minimum requirements you think it needs to run as in GPU(vram)/cpu(cores)/ram_size

@ramsaipv I used text generation web ui (oobagooba), the simplest way to infrence tbh. and i used the llamacpp loader. Which actually runs llamacpp-python if you didnt know

Oh and requirements are on the blokes page for vram usage, refer to that for each version of the models quantizations

It's almost a 1:1 copy of this: https://www.geeksforgeeks.org/create-a-snake-game-using-turtle-in-python/

When testing a coding model you should test it with novel tasks, not things it likely has been fine-tuned with intensely.

Thats great lol

deleted

I have been testing, and while its faster, its not doing as well as wizard coder for me. It even came back with functions in libraries that were mis-spelled. Sure, easily fixable as they called the function correctly, but really?

I have been testing, and while its faster, its not doing as well as wizard coder for me. It even came back with functions in libraries that were mis-spelled. Sure, easily fixable as they called the function correctly, but really?

I think you should try the much better and faster (magicoder s-cl) which worked great for me I downloaded my model from LoneStriker (just needed to create a instruct template for it to work)

deleted

I think you should try the much better and faster (magicoder s-cl) which worked great for me I downloaded my model from LoneStriker (just needed to create a instruct template for it to work)

I thought i read 'd' was the best of the sets as far as quality output, but i can try that this weekend too. nothing to lose.

Can you provide me the documentations for it? It would be really kind to me.......

Sign up or log in to comment