You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
157 lines
5.1 KiB
157 lines
5.1 KiB
# `BioGPT` Documentation
|
|
|
|
## Table of Contents
|
|
1. [Introduction](#introduction)
|
|
2. [Overview](#overview)
|
|
3. [Installation](#installation)
|
|
4. [Usage](#usage)
|
|
1. [BioGPT Class](#biogpt-class)
|
|
2. [Examples](#examples)
|
|
5. [Additional Information](#additional-information)
|
|
6. [Conclusion](#conclusion)
|
|
|
|
---
|
|
|
|
## 1. Introduction <a name="introduction"></a>
|
|
|
|
The `BioGPT` module is a domain-specific generative language model designed for the biomedical domain. It is built upon the powerful Transformer architecture and pretrained on a large corpus of biomedical literature. This documentation provides an extensive guide on using the `BioGPT` module, explaining its purpose, parameters, and usage.
|
|
|
|
---
|
|
|
|
## 2. Overview <a name="overview"></a>
|
|
|
|
The `BioGPT` module addresses the need for a language model specialized in the biomedical domain. Unlike general-purpose language models, `BioGPT` excels in generating coherent and contextually relevant text specific to biomedical terms and concepts. It has been evaluated on various biomedical natural language processing tasks and has demonstrated superior performance.
|
|
|
|
Key features and parameters of the `BioGPT` module include:
|
|
- `model_name`: Name of the pretrained model.
|
|
- `max_length`: Maximum length of generated text.
|
|
- `num_return_sequences`: Number of sequences to return.
|
|
- `do_sample`: Whether to use sampling in generation.
|
|
- `min_length`: Minimum length of generated text.
|
|
|
|
The `BioGPT` module is equipped with features for generating text, extracting features, and more.
|
|
|
|
---
|
|
|
|
## 3. Installation <a name="installation"></a>
|
|
|
|
Before using the `BioGPT` module, ensure you have the required dependencies installed, including the Transformers library and Torch. You can install these dependencies using pip:
|
|
|
|
```bash
|
|
pip install transformers
|
|
pip install torch
|
|
```
|
|
|
|
---
|
|
|
|
## 4. Usage <a name="usage"></a>
|
|
|
|
In this section, we'll cover how to use the `BioGPT` module effectively. It consists of the `BioGPT` class and provides examples to demonstrate its usage.
|
|
|
|
### 4.1. `BioGPT` Class <a name="biogpt-class"></a>
|
|
|
|
The `BioGPT` class is the core component of the `BioGPT` module. It is used to create a `BioGPT` instance, which can generate text, extract features, and more.
|
|
|
|
#### Parameters:
|
|
- `model_name` (str): Name of the pretrained model.
|
|
- `max_length` (int): Maximum length of generated text.
|
|
- `num_return_sequences` (int): Number of sequences to return.
|
|
- `do_sample` (bool): Whether or not to use sampling in generation.
|
|
- `min_length` (int): Minimum length of generated text.
|
|
|
|
### 4.2. Examples <a name="examples"></a>
|
|
|
|
Let's explore how to use the `BioGPT` class with different scenarios and applications.
|
|
|
|
#### Example 1: Generating Biomedical Text
|
|
|
|
```python
|
|
from swarms.models import BioGPT
|
|
|
|
# Initialize the BioGPT model
|
|
biogpt = BioGPT()
|
|
|
|
# Generate biomedical text
|
|
input_text = "The patient has a fever"
|
|
generated_text = biogpt(input_text)
|
|
|
|
print(generated_text)
|
|
```
|
|
|
|
#### Example 2: Extracting Features
|
|
|
|
```python
|
|
from swarms.models import BioGPT
|
|
|
|
# Initialize the BioGPT model
|
|
biogpt = BioGPT()
|
|
|
|
# Extract features from a biomedical text
|
|
input_text = "The patient has a fever"
|
|
features = biogpt.get_features(input_text)
|
|
|
|
print(features)
|
|
```
|
|
|
|
#### Example 3: Using Beam Search Decoding
|
|
|
|
```python
|
|
from swarms.models import BioGPT
|
|
|
|
# Initialize the BioGPT model
|
|
biogpt = BioGPT()
|
|
|
|
# Generate biomedical text using beam search decoding
|
|
input_text = "The patient has a fever"
|
|
generated_text = biogpt.beam_search_decoding(input_text)
|
|
|
|
print(generated_text)
|
|
```
|
|
|
|
### 4.3. Additional Features
|
|
|
|
The `BioGPT` class also provides additional features:
|
|
|
|
#### Set a New Pretrained Model
|
|
```python
|
|
biogpt.set_pretrained_model("new_pretrained_model")
|
|
```
|
|
|
|
#### Get the Model's Configuration
|
|
```python
|
|
config = biogpt.get_config()
|
|
print(config)
|
|
```
|
|
|
|
#### Save and Load the Model
|
|
```python
|
|
# Save the model and tokenizer to a directory
|
|
biogpt.save_model("saved_model")
|
|
|
|
# Load a model and tokenizer from a directory
|
|
biogpt.load_from_path("saved_model")
|
|
```
|
|
|
|
#### Print the Model's Architecture
|
|
```python
|
|
biogpt.print_model()
|
|
```
|
|
|
|
---
|
|
|
|
## 5. Additional Information <a name="additional-information"></a>
|
|
|
|
- **Biomedical Text Generation**: The `BioGPT` module is designed specifically for generating biomedical text, making it a valuable tool for various biomedical natural language processing tasks.
|
|
- **Feature Extraction**: It also provides the capability to extract features from biomedical text.
|
|
- **Beam Search Decoding**: Beam search decoding is available for generating text with improved quality.
|
|
- **Customization**: You can set a new pretrained model and save/load models for customization.
|
|
|
|
---
|
|
|
|
## 6. Conclusion <a name="conclusion"></a>
|
|
|
|
The `BioGPT` module is a powerful and specialized tool for generating and working with biomedical text. This documentation has provided a comprehensive guide on its usage, parameters, and examples, enabling you to effectively leverage it for various biomedical natural language processing tasks.
|
|
|
|
By using `BioGPT`, you can enhance your biomedical text generation and analysis tasks with contextually relevant and coherent text.
|
|
|
|
*Please check the official `BioGPT` repository and documentation for any updates beyond the knowledge cutoff date.* |