Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bae0c79f6f | ||
|
|
0d4c9808c4 | ||
|
|
cd48078ce5 | ||
|
|
727ab9d398 | ||
|
|
c95fae6d65 |
2
setup.py
2
setup.py
@@ -282,7 +282,7 @@ install_requires = [
|
||||
|
||||
setup(
|
||||
name="transformers",
|
||||
version="4.3.1", # expected format is one of x.y.z.dev0, or x.y.z.rc1 or x.y.z (no to dashes, yes to dots)
|
||||
version="4.3.3", # expected format is one of x.y.z.dev0, or x.y.z.rc1 or x.y.z (no to dashes, yes to dots)
|
||||
author="Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Sam Shleifer, Patrick von Platen, Sylvain Gugger, Google AI Language Team Authors, Open AI team Authors, Facebook AI Authors, Carnegie Mellon University Authors",
|
||||
author_email="thomas@huggingface.co",
|
||||
description="State-of-the-art Natural Language Processing for TensorFlow 2.0 and PyTorch",
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
# to defer the actual importing for when the objects are requested. This way `import transformers` provides the names
|
||||
# in the namespace without actually importing anything (and especially none of the backends).
|
||||
|
||||
__version__ = "4.3.1"
|
||||
__version__ = "4.3.3"
|
||||
|
||||
# Work around to update TensorFlow's absl.logging threshold which alters the
|
||||
# default Python logging output behavior when present.
|
||||
|
||||
@@ -144,7 +144,11 @@ try:
|
||||
_faiss_version = importlib_metadata.version("faiss")
|
||||
logger.debug(f"Successfully imported faiss version {_faiss_version}")
|
||||
except importlib_metadata.PackageNotFoundError:
|
||||
_faiss_available = False
|
||||
try:
|
||||
_faiss_version = importlib_metadata.version("faiss-cpu")
|
||||
logger.debug(f"Successfully imported faiss version {_faiss_version}")
|
||||
except importlib_metadata.PackageNotFoundError:
|
||||
_faiss_available = False
|
||||
|
||||
|
||||
_scatter_available = importlib.util.find_spec("torch_scatter") is not None
|
||||
|
||||
@@ -56,7 +56,11 @@ def convert_tf_weight_name_to_pt_weight_name(tf_name, start_prefix_to_remove="")
|
||||
tf_name = tf_name[1:] # Remove level zero
|
||||
|
||||
# When should we transpose the weights
|
||||
transpose = bool(tf_name[-1] == "kernel" or "emb_projs" in tf_name or "out_projs" in tf_name)
|
||||
transpose = bool(
|
||||
tf_name[-1] in ["kernel", "pointwise_kernel", "depthwise_kernel"]
|
||||
or "emb_projs" in tf_name
|
||||
or "out_projs" in tf_name
|
||||
)
|
||||
|
||||
# Convert standard TF2.0 names in PyTorch names
|
||||
if tf_name[-1] == "kernel" or tf_name[-1] == "embeddings" or tf_name[-1] == "gamma":
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
import argparse
|
||||
|
||||
from transformers import ConvBertConfig, ConvBertModel, load_tf_weights_in_convbert
|
||||
from transformers import ConvBertConfig, ConvBertModel, TFConvBertModel, load_tf_weights_in_convbert
|
||||
from transformers.utils import logging
|
||||
|
||||
|
||||
@@ -30,6 +30,9 @@ def convert_orig_tf1_checkpoint_to_pytorch(tf_checkpoint_path, convbert_config_f
|
||||
model = load_tf_weights_in_convbert(model, conf, tf_checkpoint_path)
|
||||
model.save_pretrained(pytorch_dump_path)
|
||||
|
||||
tf_model = TFConvBertModel.from_pretrained(pytorch_dump_path, from_pt=True)
|
||||
tf_model.save_pretrained(pytorch_dump_path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
@@ -425,7 +425,7 @@ class GroupedLinearLayer(tf.keras.layers.Layer):
|
||||
def build(self, input_shape):
|
||||
self.kernel = self.add_weight(
|
||||
"kernel",
|
||||
shape=[self.num_groups, self.group_in_dim, self.group_out_dim],
|
||||
shape=[self.group_out_dim, self.group_in_dim, self.num_groups],
|
||||
initializer=self.kernel_initializer,
|
||||
trainable=True,
|
||||
)
|
||||
@@ -437,7 +437,7 @@ class GroupedLinearLayer(tf.keras.layers.Layer):
|
||||
def call(self, hidden_states):
|
||||
batch_size = shape_list(hidden_states)[0]
|
||||
x = tf.transpose(tf.reshape(hidden_states, [-1, self.num_groups, self.group_in_dim]), [1, 0, 2])
|
||||
x = tf.matmul(x, self.kernel)
|
||||
x = tf.matmul(x, tf.transpose(self.kernel, [2, 1, 0]))
|
||||
x = tf.transpose(x, [1, 0, 2])
|
||||
x = tf.reshape(x, [batch_size, -1, self.output_size])
|
||||
x = tf.nn.bias_add(value=x, bias=self.bias)
|
||||
|
||||
@@ -1306,6 +1306,7 @@ class RagTokenForGeneration(RagPreTrainedModel):
|
||||
eos_token_id=None,
|
||||
length_penalty=None,
|
||||
no_repeat_ngram_size=None,
|
||||
encoder_no_repeat_ngram_size=None,
|
||||
repetition_penalty=None,
|
||||
bad_words_ids=None,
|
||||
num_return_sequences=None,
|
||||
@@ -1372,6 +1373,9 @@ class RagTokenForGeneration(RagPreTrainedModel):
|
||||
order to encourage the model to produce longer sequences.
|
||||
no_repeat_ngram_size (:obj:`int`, `optional`, defaults to 0):
|
||||
If set to int > 0, all ngrams of that size can only occur once.
|
||||
encoder_no_repeat_ngram_size (:obj:`int`, `optional`, defaults to 0):
|
||||
If set to int > 0, all ngrams of that size that occur in the ``encoder_input_ids`` cannot occur in the
|
||||
``decoder_input_ids``.
|
||||
bad_words_ids(:obj:`List[int]`, `optional`):
|
||||
List of token ids that are not allowed to be generated. In order to get the tokens of the words that
|
||||
should not appear in the generated text, use :obj:`tokenizer.encode(bad_word, add_prefix_space=True)`.
|
||||
@@ -1490,6 +1494,8 @@ class RagTokenForGeneration(RagPreTrainedModel):
|
||||
pre_processor = self._get_logits_processor(
|
||||
repetition_penalty=repetition_penalty,
|
||||
no_repeat_ngram_size=no_repeat_ngram_size,
|
||||
encoder_no_repeat_ngram_size=encoder_no_repeat_ngram_size,
|
||||
encoder_input_ids=context_input_ids,
|
||||
bad_words_ids=bad_words_ids,
|
||||
min_length=min_length,
|
||||
eos_token_id=eos_token_id,
|
||||
|
||||
@@ -384,8 +384,6 @@ class TFConvBertModelIntegrationTest(unittest.TestCase):
|
||||
expected_shape = [1, 6, 768]
|
||||
self.assertEqual(output.shape, expected_shape)
|
||||
|
||||
print(output[:, :3, :3])
|
||||
|
||||
expected_slice = tf.constant(
|
||||
[
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user