Skip to content

Commit

Permalink
fix: use the model revision in bento info for huggingface models (#5053)
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming authored Oct 31, 2024
1 parent 241528a commit 2f5dca7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/_bentoml_sdk/models/huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,14 @@ def from_info(cls, info: BentoModelInfo) -> HuggingFaceModel:
if not info.metadata:
name, revision = info.tag.name, info.tag.version
return cls(model_id=name.replace("--", "/"), revision=revision or "main")
return cls(
model = cls(
model_id=info.metadata["model_id"],
revision=info.metadata["revision"],
endpoint=info.metadata["endpoint"],
)
# the commit hash is frozen in the model info, update the cache directly
model.__dict__.update(commit_hash=info.metadata["revision"])
return model

def _get_model_size(self, revision: str) -> int:
info = self._hf_api.model_info(
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/frameworks/models/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class NativeModel(tf.Module):
def __init__(self):
super().__init__()
self.weights = np.asfarray([[1.0], [1.0], [1.0], [1.0], [1.0]])
self.weights = np.asarray([[1.0], [1.0], [1.0], [1.0], [1.0]], dtype=np.float64)
self.dense = lambda inputs: tf.matmul(inputs, self.weights)

@tf.function(
Expand All @@ -47,7 +47,7 @@ def predict_ragged(self, inputs):
class MultiInputModel(tf.Module):
def __init__(self):
super().__init__()
self.weights = np.asfarray([[1.0], [1.0], [1.0], [1.0], [1.0]])
self.weights = np.asarray([[1.0], [1.0], [1.0], [1.0], [1.0]], dtype=np.float64)
self.dense = lambda tensor: tf.matmul(tensor, self.weights)

@tf.function(
Expand Down

0 comments on commit 2f5dca7

Please sign in to comment.