Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

albert pretrained example


from transformers import AlbertTokenizer, AlbertForQuestionAnswering
import torch

tokenizer = AlbertTokenizer.from_pretrained('albert-base-v2')
model = AlbertForQuestionAnswering.from_pretrained('albert-base-v2')
question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"
input_dict = tokenizer.encode_plus(question, text, return_tensors='pt')
start_scores, end_scores = model(**input_dict)
Comment

albert pretrained example


from transformers import AlbertTokenizer, AlbertForQuestionAnswering
import torch

MODEL_PATH = 'ktrapeznikov/albert-xlarge-v2-squad-v2';

tokenizer = AlbertTokenizer.from_pretrained(MODEL_PATH)
model = AlbertForQuestionAnswering.from_pretrained(MODEL_PATH)

Comment

PREVIOUS NEXT
Code Example
Python :: python pickle save and load multiple variables 
Python :: torch concat matrix 
Python :: python make button do more than one command 
Python :: rock paper scissors game in python 
Python :: choosing the correct lower and upper bounds in cv2 
Python :: how to do processing on html file using python 
Python :: somma in python 
Python :: pandas select column by index 
Python :: python scatterplot figsize 
Python :: how to know how much lines a file has using python 
Python :: tqdm remove progress bar when done 
Python :: pandas count rows with value 
Python :: python one line return 
Python :: python hex to bytes string 
Python :: keras auc without tf.metrics.auc 
Python :: find frequency of each word in a string in python using dictionary 
Python :: append to list in dictionary python if exists 
Python :: check if numpy array is 1d 
Python :: python number of elements in multidimensional array 
Python :: python how often element in list 
Python :: native bold text 
Python :: pyautogui install 
Python :: askopenfilename 
Python :: convert dictionary to spark dataframe python 
Python :: position in list python 
Python :: face detection 
Python :: os walk example 
Python :: likeliness python 
Python :: streamlit dropdown 
Python :: python windows take screenshot pil 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =