Skip to main content

convmodel provides a conversation model based on decoders models.

Project description

convmodel

convmodel provides a conversation model based on transformers GPT-2 model :wink:

:sparkles: Features :sparkles:

  • Utilizes GPT2 model to generate response
  • Handles multi-turn conversation
  • Provides useuful interfaces to fine-tune model and generate a response from a given context

A simple example of fine-tune GPT-2 model and generate a response:

from convmodel import ConversationModel
from convmodel import ConversationExample

# Load model on GPU
model = ConversationModel.from_pretrained("gpt2")

# Define training/validation examples
train_iterator = [
    ConversationExample(conversation=[
        "Hello",
        "Hi, how are you?",
        "Good, thank you, how about you?",
        "Good, thanks!"
    ]),
    ConversationExample(conversation=[
        "I am hungry",
        "How about eating pizza?"
    ]),
]
valid_iterator = [
    ConversationExample(conversation=[
        "Tired...",
        "Let's have a break!",
        "Nice idea!"
    ]),
]

# Fine-tune model
model.fit(train_iterator=train_iterator, valid_iterator=valid_iterator)

# Generate response
model.generate(context=["Hello", "How are you"], do_sample=True, top_p=0.95, top_k=50)
# Output could be like below if sufficient examples were given.
# => ConversationModelOutput(responses=['Good thank you'], context=['Hello', 'How are you'])

Please refer to document for more details of installation, model architecture and usage.

Enjoy talking with your conversational AI :wink:

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

convmodel-0.3.0.tar.gz (9.9 kB view details)

Uploaded Source

File details

Details for the file convmodel-0.3.0.tar.gz.

File metadata

  • Download URL: convmodel-0.3.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.6

File hashes

Hashes for convmodel-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e18af32ddea214cb7d32149ec0eddafd273c89aa16e659579461bbd9b3ad551a
MD5 92ee3bb382b12d56631e887d0f35f5e3
BLAKE2b-256 0ad2cf75b0c038cfa404996223bb860933c3c525bfce85ad82243e62938522a3

See more details on using hashes here.

Supported by

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