Snippets Collections
import json
import requests
API_URL = ""
headers = {"Authorization": f"Bearer {API_TOKEN}"}
def query(payload):
    data = json.dumps(payload)
    response = requests.request("POST", API_URL, headers=headers, data=data)
    return json.loads(response.content.decode("utf-8"))
data = query("Can you please let us know more details about your ")
!git clone
!pip install transformers
!pip install datasets
!pip install huggingface-hub==0.4.0
def deleteEncodingLayers(model, num_layers_to_keep):  # must pass in the full bert model
    oldModuleList = model.bert.encoder.layer
    newModuleList = nn.ModuleList()

    # Now iterate over all layers, only keepign only the relevant layers.
    for i in range(0, len(num_layers_to_keep)):

    # create a copy of the model, modify it with the new list, and return
    copyOfModel = copy.deepcopy(model)
    copyOfModel.bert.encoder.layer = newModuleList

    return copyOfModel

Mon Jul 24 2023 02:28:33 GMT+0000 (Coordinated Universal Time)

#huggingface #hf #api

Mon Jul 24 2023 02:26:25 GMT+0000 (Coordinated Universal Time)

#huggingface #hf

Mon Mar 07 2022 06:29:49 GMT+0000 (Coordinated Universal Time)

#python #huggingface

Fri Aug 06 2021 12:24:19 GMT+0000 (Coordinated Universal Time)

#python #huggingface #nlp

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension