Skip to main content

AI made easy. Based on pytorch.

Project description

Pytrainer

AI made Easy.

Tutorials

Train and Save a Model

from pytrainer.text import TextAI

# Create an instance of TextAI
ai = TextAI()

# Define some simple training data (input-output pairs)
training_data = {
    "Hello": "Hi there!",
    "How are you?": "I'm good, thank you!",
    "What's your name?": "I am TextAI."
}

# Train the model
ai.train(training_data, epochs=10, batch_size=1, learning_rate=0.001)

# Save the trained model
ai.save('trained_model.json')

Load and Prompt the Model

from pytrainer.text import TextAI

# Create a new instance of TextAI and load the trained model
ai_new = TextAI()
ai_new.load('trained_model.json')

# Generate a response to a new prompt
response = ai_new.prompt("What's your name?")
print(response)

Classes

TextAI

from pytrainer.text import TextAI

train(self, data, epochs=10, batch_size=1, learning_rate=0.001)

  • Arguments:
    • data: A dictionary of input-output pairs for training (required).
    • epochs: The number of training epochs (default is 10).
    • batch_size: The batch size used during training (default is 1).
    • learning_rate: The learning rate for the optimizer (default is 0.001).

prompt(self, input_text, max_length=50, temperature=0.5)

  • Arguments:
    • input_text: The text prompt to generate a response for (required).
    • max_length: The maximum length of the generated response (default is 50).
    • temperature: Controls the randomness of the generated text (default is 0.5).

save(self, path)

  • Arguments:
    • path: The file path to save the model data (required).

load(self, path)

  • Arguments:
    • path: The file path from which to load the model data (required).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytrainer-0.0.1.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytrainer-0.0.1-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file pytrainer-0.0.1.tar.gz.

File metadata

  • Download URL: pytrainer-0.0.1.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.0

File hashes

Hashes for pytrainer-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a2d4714af4130806063b5901193d4fc072a21def2dd5c811f1607a7296f32e30
MD5 56f704e785b7a5a1216554b52c7401dc
BLAKE2b-256 3e466c65245a0c72605ec179d59031b2de678979b531d9871a171c2aea0aa49c

See more details on using hashes here.

File details

Details for the file pytrainer-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pytrainer-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.0

File hashes

Hashes for pytrainer-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6a2f610ce1c1165f6e81695c005be08a510fb10cd0c597c35373b539e25bbc78
MD5 119e4128452b0cac640ede7dcd0c9990
BLAKE2b-256 49395e3d82aab1f8855ea358d8b155f08e1370c2e09a083d3a0d488a500a0737

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page