Jonatasgrosman/wav2vec2-large-xlsr-53-english model: Difference between revisions

From AI Wiki
No edit summary
No edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 8: Line 8:
| language = English
| language = English
| paper =  
| paper =  
| related-to = wav2vec2, audio, hf-asr-leaderboard, mozilla-foundation/common_voice_6_0, robust-speech-event, speech, xlsr-fine-tuning-week
| license = apache-2.0
| license = apache-2.0
| related-to = wav2vec2, audio, hf-asr-leaderboard, mozilla-foundation/common_voice_6_0, robust-speech-event, speech, xlsr-fine-tuning-week, Eval Results
| all-tags = Automatic Speech Recognition, PyTorch, JAX, Safetensors, Transformers, common_voice, mozilla-foundation/common_voice_6_0, English, wav2vec2, audio, hf-asr-leaderboard, mozilla-foundation/common_voice_6_0, robust-speech-event, speech, xlsr-fine-tuning-week, Eval Results, License: apache-2.0
| all-tags = Automatic Speech Recognition, PyTorch, JAX, Safetensors, Transformers, common_voice, mozilla-foundation/common_voice_6_0, English, wav2vec2, audio, hf-asr-leaderboard, mozilla-foundation/common_voice_6_0, robust-speech-event, speech, xlsr-fine-tuning-week, Eval Results, License: apache-2.0
| all-lang-tags = English
| all-lang-tags = English
}}
}}
==Model Description==


==Clone Model Repository==
==Clone Model Repository==
Line 38: Line 40:
</pre>
</pre>
</tabber>
</tabber>


==Hugging Face Transformers Library==
==Hugging Face Transformers Library==
Line 48: Line 49:
model = AutoModelForCTC.from_pretrained("jonatasgrosman/wav2vec2-large-xlsr-53-english")
model = AutoModelForCTC.from_pretrained("jonatasgrosman/wav2vec2-large-xlsr-53-english")
</pre>
</pre>


==Deployment==
==Deployment==
Line 101: Line 101:
<tabber>
<tabber>
|-|Automatic Speech Recognition=
|-|Automatic Speech Recognition=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 132: Line 133:
})
})
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 164: Line 166:
})
})
</pre>
</pre>
}}
|-|Conversational=
|-|Conversational=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 196: Line 200:
})
})
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 228: Line 233:
})
})
</pre>
</pre>
}}
|-|Feature Extraction=
|-|Feature Extraction=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 260: Line 267:
})
})
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 292: Line 300:
})
})
</pre>
</pre>
}}
|-|Fill-Mask=
|-|Fill-Mask=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 324: Line 334:
})
})
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 356: Line 367:
})
})
</pre>
</pre>
}}
|-|Image Classification=
|-|Image Classification=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 388: Line 401:
})
})
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 420: Line 434:
})
})
</pre>
</pre>
}}
|-|Question Answering=
|-|Question Answering=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 452: Line 468:
})
})
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 484: Line 501:
})
})
</pre>
</pre>
}}
|-|Summarization=
|-|Summarization=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 516: Line 535:
})
})
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 548: Line 568:
})
})
</pre>
</pre>
}}
|-|Table Question Answering=
|-|Table Question Answering=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 580: Line 602:
})
})
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 612: Line 635:
})
})
</pre>
</pre>
}}
|-|Text Classification=
|-|Text Classification=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 644: Line 669:
})
})
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 676: Line 702:
})
})
</pre>
</pre>
}}
|-|Text Generation=
|-|Text Generation=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 708: Line 736:
})
})
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 740: Line 769:
})
})
</pre>
</pre>
}}
|-|Text2Text Generation=
|-|Text2Text Generation=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 772: Line 803:
})
})
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 804: Line 836:
})
})
</pre>
</pre>
}}
|-|Token Classification=
|-|Token Classification=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 836: Line 870:
})
})
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 868: Line 903:
})
})
</pre>
</pre>
}}
|-|Translation=
|-|Translation=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 900: Line 937:
})
})
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 932: Line 970:
})
})
</pre>
</pre>
}}
|-|Zero-Shot Classification=
|-|Zero-Shot Classification=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 964: Line 1,004:
})
})
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.huggingface import HuggingFaceModel
Line 996: Line 1,037:
})
})
</pre>
</pre>
}}
</tabber>
</tabber>


Line 1,004: Line 1,046:
gr.Interface.load("models/jonatasgrosman/wav2vec2-large-xlsr-53-english").launch()
gr.Interface.load("models/jonatasgrosman/wav2vec2-large-xlsr-53-english").launch()
</pre>
</pre>


==Training==
==Training==
Line 1,010: Line 1,051:
<tabber>
<tabber>
|-|Causal Language Modeling=
|-|Causal Language Modeling=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
import sagemaker
import sagemaker
Line 1,044: Line 1,086:
huggingface_estimator.fit()
huggingface_estimator.fit()
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
import sagemaker
import sagemaker
Line 1,080: Line 1,123:
huggingface_estimator.fit()
huggingface_estimator.fit()
</pre>
</pre>
}}
|-|Masked Language Modeling=
|-|Masked Language Modeling=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
import sagemaker
import sagemaker
Line 1,115: Line 1,160:
huggingface_estimator.fit()
huggingface_estimator.fit()
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
import sagemaker
import sagemaker
Line 1,151: Line 1,197:
huggingface_estimator.fit()
huggingface_estimator.fit()
</pre>
</pre>
}}
|-|Question Answering=
|-|Question Answering=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
import sagemaker
import sagemaker
Line 1,186: Line 1,234:
huggingface_estimator.fit()
huggingface_estimator.fit()
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
import sagemaker
import sagemaker
Line 1,222: Line 1,271:
huggingface_estimator.fit()
huggingface_estimator.fit()
</pre>
</pre>
}}
|-|Summarization=
|-|Summarization=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
import sagemaker
import sagemaker
Line 1,257: Line 1,308:
huggingface_estimator.fit()
huggingface_estimator.fit()
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
import sagemaker
import sagemaker
Line 1,293: Line 1,345:
huggingface_estimator.fit()
huggingface_estimator.fit()
</pre>
</pre>
}}
|-|Text Classification=
|-|Text Classification=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
import sagemaker
import sagemaker
Line 1,328: Line 1,382:
huggingface_estimator.fit()
huggingface_estimator.fit()
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
import sagemaker
import sagemaker
Line 1,364: Line 1,419:
huggingface_estimator.fit()
huggingface_estimator.fit()
</pre>
</pre>
}}
|-|Token Classification=
|-|Token Classification=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
import sagemaker
import sagemaker
Line 1,399: Line 1,456:
huggingface_estimator.fit()
huggingface_estimator.fit()
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
import sagemaker
import sagemaker
Line 1,435: Line 1,493:
huggingface_estimator.fit()
huggingface_estimator.fit()
</pre>
</pre>
}}
|-|Translation=
|-|Translation=
=====AWS=====
{{#tag:tabber|
AWS=
<pre>
<pre>
import sagemaker
import sagemaker
Line 1,470: Line 1,530:
huggingface_estimator.fit()
huggingface_estimator.fit()
</pre>
</pre>
=====Local Machine=====
{{!}}-{{!}}
Local Machine=
<pre>
<pre>
import sagemaker
import sagemaker
Line 1,506: Line 1,567:
huggingface_estimator.fit()
huggingface_estimator.fit()
</pre>
</pre>
}}
</tabber>
</tabber>


==Model Card==


==Model Card==
==Comments==
<comments />

Latest revision as of 03:33, 23 May 2023

Jonatasgrosman/wav2vec2-large-xlsr-53-english model is a Audio model used for Automatic Speech Recognition.

Model Description

Clone Model Repository

#Be sure to have git-lfs installed (https://git-lfs.com)
git lfs install
git clone https://huggingface.co/jonatasgrosman/wav2vec2-large-xlsr-53-english
  
#To clone the repo without large files – just their pointers
#prepend git clone with the following env var:
GIT_LFS_SKIP_SMUDGE=1

#Be sure to have git-lfs installed (https://git-lfs.com)
git lfs install
git clone [email protected]:jonatasgrosman/wav2vec2-large-xlsr-53-english
  
#To clone the repo without large files – just their pointers
#prepend git clone with the following env var:
GIT_LFS_SKIP_SMUDGE=1

Hugging Face Transformers Library

from transformers import AutoProcessor, AutoModelForCTC

processor = AutoProcessor.from_pretrained("jonatasgrosman/wav2vec2-large-xlsr-53-english")

model = AutoModelForCTC.from_pretrained("jonatasgrosman/wav2vec2-large-xlsr-53-english")

Deployment

Inference API

import requests

API_URL = "https://api-inference.huggingface.co/models/jonatasgrosman/wav2vec2-large-xlsr-53-english"
headers = {"Authorization": f"Bearer {API_TOKEN}"}

def query(filename):
    with open(filename, "rb") as f:
        data = f.read()
    response = requests.post(API_URL, headers=headers, data=data)
    return response.json()

output = query("sample1.flac")

async function query(filename) {
	const data = fs.readFileSync(filename);
	const response = await fetch(
		"https://api-inference.huggingface.co/models/jonatasgrosman/wav2vec2-large-xlsr-53-english",
		{
			headers: { Authorization: "Bearer {API_TOKEN}" },
			method: "POST",
			body: data,
		}
	);
	const result = await response.json();
	return result;
}

query("sample1.flac").then((response) => {
	console.log(JSON.stringify(response));
});

curl https://api-inference.huggingface.co/models/jonatasgrosman/wav2vec2-large-xlsr-53-english \
	-X POST \
	--data-binary '@sample1.flac' \
	-H "Authorization: Bearer {API_TOKEN}"

Amazon SageMaker

from sagemaker.huggingface import HuggingFaceModel
import sagemaker

role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'automatic-speech-recognition'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import boto3

iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'automatic-speech-recognition'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import sagemaker

role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'conversational'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import boto3

iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'conversational'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import sagemaker

role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'feature-extraction'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import boto3

iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'feature-extraction'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import sagemaker

role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'fill-mask'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import boto3

iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'fill-mask'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import sagemaker

role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'image-classification'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import boto3

iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'image-classification'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import sagemaker

role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'question-answering'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import boto3

iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'question-answering'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import sagemaker

role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'summarization'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import boto3

iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'summarization'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import sagemaker

role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'table-question-answering'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import boto3

iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'table-question-answering'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import sagemaker

role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'text-classification'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import boto3

iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'text-classification'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import sagemaker

role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'text-generation'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import boto3

iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'text-generation'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import sagemaker

role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'text2text-generation'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import boto3

iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'text2text-generation'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import sagemaker

role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'token-classification'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import boto3

iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'token-classification'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import sagemaker

role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'translation'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import boto3

iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'translation'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import sagemaker

role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'zero-shot-classification'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

from sagemaker.huggingface import HuggingFaceModel
import boto3

iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'HF_TASK':'zero-shot-classification'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})

Spaces

import gradio as gr

gr.Interface.load("models/jonatasgrosman/wav2vec2-large-xlsr-53-english").launch()

Training

Amazon SageMaker

import sagemaker
from sagemaker.huggingface import HuggingFace

# gets role for executing training job
role = sagemaker.get_execution_role()
hyperparameters = {
	'model_name_or_path':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'output_dir':'/opt/ml/model'
	# add your remaining hyperparameters
	# more info here https://github.com/huggingface/transformers/tree/v4.17.0/examples/pytorch/language-modeling
}

# git configuration to download our fine-tuning script
git_config = {'repo': 'https://github.com/huggingface/transformers.git','branch': 'v4.17.0'}

# creates Hugging Face estimator
huggingface_estimator = HuggingFace(
	entry_point='run_clm.py',
	source_dir='./examples/pytorch/language-modeling',
	instance_type='ml.p3.2xlarge',
	instance_count=1,
	role=role,
	git_config=git_config,
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	hyperparameters = hyperparameters
)

# starting the train job
huggingface_estimator.fit()

import sagemaker
import boto3
from sagemaker.huggingface import HuggingFace

# gets role for executing training job
iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
hyperparameters = {
	'model_name_or_path':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'output_dir':'/opt/ml/model'
	# add your remaining hyperparameters
	# more info here https://github.com/huggingface/transformers/tree/v4.17.0/examples/pytorch/language-modeling
}

# git configuration to download our fine-tuning script
git_config = {'repo': 'https://github.com/huggingface/transformers.git','branch': 'v4.17.0'}

# creates Hugging Face estimator
huggingface_estimator = HuggingFace(
	entry_point='run_clm.py',
	source_dir='./examples/pytorch/language-modeling',
	instance_type='ml.p3.2xlarge',
	instance_count=1,
	role=role,
	git_config=git_config,
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	hyperparameters = hyperparameters
)

# starting the train job
huggingface_estimator.fit()

import sagemaker
from sagemaker.huggingface import HuggingFace

# gets role for executing training job
role = sagemaker.get_execution_role()
hyperparameters = {
	'model_name_or_path':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'output_dir':'/opt/ml/model'
	# add your remaining hyperparameters
	# more info here https://github.com/huggingface/transformers/tree/v4.17.0/examples/pytorch/language-modeling
}

# git configuration to download our fine-tuning script
git_config = {'repo': 'https://github.com/huggingface/transformers.git','branch': 'v4.17.0'}

# creates Hugging Face estimator
huggingface_estimator = HuggingFace(
	entry_point='run_mlm.py',
	source_dir='./examples/pytorch/language-modeling',
	instance_type='ml.p3.2xlarge',
	instance_count=1,
	role=role,
	git_config=git_config,
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	hyperparameters = hyperparameters
)

# starting the train job
huggingface_estimator.fit()

import sagemaker
import boto3
from sagemaker.huggingface import HuggingFace

# gets role for executing training job
iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
hyperparameters = {
	'model_name_or_path':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'output_dir':'/opt/ml/model'
	# add your remaining hyperparameters
	# more info here https://github.com/huggingface/transformers/tree/v4.17.0/examples/pytorch/language-modeling
}

# git configuration to download our fine-tuning script
git_config = {'repo': 'https://github.com/huggingface/transformers.git','branch': 'v4.17.0'}

# creates Hugging Face estimator
huggingface_estimator = HuggingFace(
	entry_point='run_mlm.py',
	source_dir='./examples/pytorch/language-modeling',
	instance_type='ml.p3.2xlarge',
	instance_count=1,
	role=role,
	git_config=git_config,
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	hyperparameters = hyperparameters
)

# starting the train job
huggingface_estimator.fit()

import sagemaker
from sagemaker.huggingface import HuggingFace

# gets role for executing training job
role = sagemaker.get_execution_role()
hyperparameters = {
	'model_name_or_path':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'output_dir':'/opt/ml/model'
	# add your remaining hyperparameters
	# more info here https://github.com/huggingface/transformers/tree/v4.17.0/examples/pytorch/question-answering
}

# git configuration to download our fine-tuning script
git_config = {'repo': 'https://github.com/huggingface/transformers.git','branch': 'v4.17.0'}

# creates Hugging Face estimator
huggingface_estimator = HuggingFace(
	entry_point='run_qa.py',
	source_dir='./examples/pytorch/question-answering',
	instance_type='ml.p3.2xlarge',
	instance_count=1,
	role=role,
	git_config=git_config,
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	hyperparameters = hyperparameters
)

# starting the train job
huggingface_estimator.fit()

import sagemaker
import boto3
from sagemaker.huggingface import HuggingFace

# gets role for executing training job
iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
hyperparameters = {
	'model_name_or_path':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'output_dir':'/opt/ml/model'
	# add your remaining hyperparameters
	# more info here https://github.com/huggingface/transformers/tree/v4.17.0/examples/pytorch/question-answering
}

# git configuration to download our fine-tuning script
git_config = {'repo': 'https://github.com/huggingface/transformers.git','branch': 'v4.17.0'}

# creates Hugging Face estimator
huggingface_estimator = HuggingFace(
	entry_point='run_qa.py',
	source_dir='./examples/pytorch/question-answering',
	instance_type='ml.p3.2xlarge',
	instance_count=1,
	role=role,
	git_config=git_config,
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	hyperparameters = hyperparameters
)

# starting the train job
huggingface_estimator.fit()

import sagemaker
from sagemaker.huggingface import HuggingFace

# gets role for executing training job
role = sagemaker.get_execution_role()
hyperparameters = {
	'model_name_or_path':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'output_dir':'/opt/ml/model'
	# add your remaining hyperparameters
	# more info here https://github.com/huggingface/transformers/tree/v4.17.0/examples/pytorch/seq2seq
}

# git configuration to download our fine-tuning script
git_config = {'repo': 'https://github.com/huggingface/transformers.git','branch': 'v4.17.0'}

# creates Hugging Face estimator
huggingface_estimator = HuggingFace(
	entry_point='run_summarization.py',
	source_dir='./examples/pytorch/seq2seq',
	instance_type='ml.p3.2xlarge',
	instance_count=1,
	role=role,
	git_config=git_config,
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	hyperparameters = hyperparameters
)

# starting the train job
huggingface_estimator.fit()

import sagemaker
import boto3
from sagemaker.huggingface import HuggingFace

# gets role for executing training job
iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
hyperparameters = {
	'model_name_or_path':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'output_dir':'/opt/ml/model'
	# add your remaining hyperparameters
	# more info here https://github.com/huggingface/transformers/tree/v4.17.0/examples/pytorch/seq2seq
}

# git configuration to download our fine-tuning script
git_config = {'repo': 'https://github.com/huggingface/transformers.git','branch': 'v4.17.0'}

# creates Hugging Face estimator
huggingface_estimator = HuggingFace(
	entry_point='run_summarization.py',
	source_dir='./examples/pytorch/seq2seq',
	instance_type='ml.p3.2xlarge',
	instance_count=1,
	role=role,
	git_config=git_config,
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	hyperparameters = hyperparameters
)

# starting the train job
huggingface_estimator.fit()

import sagemaker
from sagemaker.huggingface import HuggingFace

# gets role for executing training job
role = sagemaker.get_execution_role()
hyperparameters = {
	'model_name_or_path':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'output_dir':'/opt/ml/model'
	# add your remaining hyperparameters
	# more info here https://github.com/huggingface/transformers/tree/v4.17.0/examples/pytorch/text-classification
}

# git configuration to download our fine-tuning script
git_config = {'repo': 'https://github.com/huggingface/transformers.git','branch': 'v4.17.0'}

# creates Hugging Face estimator
huggingface_estimator = HuggingFace(
	entry_point='run_glue.py',
	source_dir='./examples/pytorch/text-classification',
	instance_type='ml.p3.2xlarge',
	instance_count=1,
	role=role,
	git_config=git_config,
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	hyperparameters = hyperparameters
)

# starting the train job
huggingface_estimator.fit()

import sagemaker
import boto3
from sagemaker.huggingface import HuggingFace

# gets role for executing training job
iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
hyperparameters = {
	'model_name_or_path':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'output_dir':'/opt/ml/model'
	# add your remaining hyperparameters
	# more info here https://github.com/huggingface/transformers/tree/v4.17.0/examples/pytorch/text-classification
}

# git configuration to download our fine-tuning script
git_config = {'repo': 'https://github.com/huggingface/transformers.git','branch': 'v4.17.0'}

# creates Hugging Face estimator
huggingface_estimator = HuggingFace(
	entry_point='run_glue.py',
	source_dir='./examples/pytorch/text-classification',
	instance_type='ml.p3.2xlarge',
	instance_count=1,
	role=role,
	git_config=git_config,
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	hyperparameters = hyperparameters
)

# starting the train job
huggingface_estimator.fit()

import sagemaker
from sagemaker.huggingface import HuggingFace

# gets role for executing training job
role = sagemaker.get_execution_role()
hyperparameters = {
	'model_name_or_path':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'output_dir':'/opt/ml/model'
	# add your remaining hyperparameters
	# more info here https://github.com/huggingface/transformers/tree/v4.17.0/examples/pytorch/token-classification
}

# git configuration to download our fine-tuning script
git_config = {'repo': 'https://github.com/huggingface/transformers.git','branch': 'v4.17.0'}

# creates Hugging Face estimator
huggingface_estimator = HuggingFace(
	entry_point='run_ner.py',
	source_dir='./examples/pytorch/token-classification',
	instance_type='ml.p3.2xlarge',
	instance_count=1,
	role=role,
	git_config=git_config,
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	hyperparameters = hyperparameters
)

# starting the train job
huggingface_estimator.fit()

import sagemaker
import boto3
from sagemaker.huggingface import HuggingFace

# gets role for executing training job
iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
hyperparameters = {
	'model_name_or_path':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'output_dir':'/opt/ml/model'
	# add your remaining hyperparameters
	# more info here https://github.com/huggingface/transformers/tree/v4.17.0/examples/pytorch/token-classification
}

# git configuration to download our fine-tuning script
git_config = {'repo': 'https://github.com/huggingface/transformers.git','branch': 'v4.17.0'}

# creates Hugging Face estimator
huggingface_estimator = HuggingFace(
	entry_point='run_ner.py',
	source_dir='./examples/pytorch/token-classification',
	instance_type='ml.p3.2xlarge',
	instance_count=1,
	role=role,
	git_config=git_config,
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	hyperparameters = hyperparameters
)

# starting the train job
huggingface_estimator.fit()

import sagemaker
from sagemaker.huggingface import HuggingFace

# gets role for executing training job
role = sagemaker.get_execution_role()
hyperparameters = {
	'model_name_or_path':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'output_dir':'/opt/ml/model'
	# add your remaining hyperparameters
	# more info here https://github.com/huggingface/transformers/tree/v4.17.0/examples/pytorch/seq2seq
}

# git configuration to download our fine-tuning script
git_config = {'repo': 'https://github.com/huggingface/transformers.git','branch': 'v4.17.0'}

# creates Hugging Face estimator
huggingface_estimator = HuggingFace(
	entry_point='run_translation.py',
	source_dir='./examples/pytorch/seq2seq',
	instance_type='ml.p3.2xlarge',
	instance_count=1,
	role=role,
	git_config=git_config,
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	hyperparameters = hyperparameters
)

# starting the train job
huggingface_estimator.fit()

import sagemaker
import boto3
from sagemaker.huggingface import HuggingFace

# gets role for executing training job
iam_client = boto3.client('iam')
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn']
hyperparameters = {
	'model_name_or_path':'jonatasgrosman/wav2vec2-large-xlsr-53-english',
	'output_dir':'/opt/ml/model'
	# add your remaining hyperparameters
	# more info here https://github.com/huggingface/transformers/tree/v4.17.0/examples/pytorch/seq2seq
}

# git configuration to download our fine-tuning script
git_config = {'repo': 'https://github.com/huggingface/transformers.git','branch': 'v4.17.0'}

# creates Hugging Face estimator
huggingface_estimator = HuggingFace(
	entry_point='run_translation.py',
	source_dir='./examples/pytorch/seq2seq',
	instance_type='ml.p3.2xlarge',
	instance_count=1,
	role=role,
	git_config=git_config,
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	hyperparameters = hyperparameters
)

# starting the train job
huggingface_estimator.fit()

Model Card

Comments

Loading comments...