Trying the Qwen3-8B Model Locally
I have been hearing a lot of good things about the qwen3-8b
model lately, in fact, I also read about it in a post by Simon.
So, I had to try it and I will be sharing my learnings in this post.
Installation
I use Ollama so the installation process was easy, I just ran the following terminal command and the model got installed within a minute. You can visit the Ollama page for qwen3 here.
ollama run qwen3:8b
For the 8b
model, it downloaded a 5.2GB file.
Initial testing
At first, I just sent "hi" and then only I got to know that it's a thinking model as its thoughts were being shown between <think>
</think>
tags. And then it replied with "Hello! 😊 How can I assist you today?" as you can see in the below screenshot.
I am using a MacBook M2 Air 16GB device and the evaluation rate was 16.34 tokens per second, as you can see in the above screenshot.
Coding test
I asked it to generate a simple tic-tac-toe game by giving it the following prompt:
create a tic tac toe game in python
And, to my surprise, it created the best tic-tac-toe game I have ever played in the terminal and it ran without any errors. If you want to take a look, below is the Python code that it gave me:
def check_winner(board, player):
# Check rows
for row in board:
if row[0] == row[1] == row[2] == player:
return True
# Check columns
for col in range(3):
if board[0][col] == board[1][col] == board[2][col] == player:
return True
# Check diagonals
if board[0][0] == board[1][1] == board[2][2] == player:
return True
if board[0][2] == board[1][1] == board[2][0] == player:
return True
return False
def is_draw(board):
for row in board:
if ' ' in row:
return False
return True
def print_board(board):
for row in board:
print('|'.join(row))
print()
def main():
board = [[' ' for _ in range(3)] for _ in range(3)]
current_player = 'X'
while True:
print_board(board)
while True:
try:
move = int(input(f"Player {current_player}, enter your move (1-9): "))
if 1 <= move <= 9:
row = (move - 1) // 3
col = (move - 1) % 3
if board[row][col] == ' ':
board[row][col] = current_player
break
else:
print("Cell already occupied. Try again.")
else:
print("Invalid input. Please enter a number between 1 and 9.")
except ValueError:
print("Invalid input. Please enter a number between 1 and 9.")
if check_winner(board, current_player):
print_board(board)
print(f"Player {current_player} wins!")
break
if is_draw(board):
print_board(board)
print("It's a draw!")
break
current_player = 'O' if current_player == 'X' else 'X'
if __name__ == "__main__":
main()
It looks like this when you play the game - it perfectly handles the win, lose, and draw cases.
| | | |
| | | |
| | | |
Player X, enter your move (1-9): 1
|X| | |
| | | |
| | | |
Player O, enter your move (1-9): 5
|X| | |
| |O| |
| | | |
Player X, enter your move (1-9): 3
|X| |X|
| |O| |
| | | |
Player O, enter your move (1-9): 7
|X| |X|
| |O| |
|O| | |
Player X, enter your move (1-9): 9
|X| |X|
| |O| |
|O| |X|
Player O, enter your move (1-9): 4
|X| |X|
|O|O| |
|O| |X|
Player X, enter your move (1-9): 6
|X| |X|
|O|O|X|
|O| |X|
Player O, enter your move (1-9): 8
|X| |X|
|O|O|X|
|O|O|X|
Player X, enter your move (1-9): 2
|X|X|X|
|O|O|X|
|O|O|X|
Player X wins!
But the only issue was, it took approximately 12 minutes to give the output as it kept thinking and thinking. I am sure that it's due to my computer's power, and it would have been faster on a computer with higher configuration.
If you want to take a look at the entire output, including the
<think>
tags, you can click here to see this .txt file.
Apart from this, I asked multiple simple coding and tech related questions and I'd say that I am very satisfied with it. It performs surprisingly well for its size.
- ← Previous
Learning about sqlite3 WASM
Comment via email