Tonic commited on
Commit
e81e85b
1 Parent(s): b5f833c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -0
app.py CHANGED
@@ -13,6 +13,8 @@ You can also use 🐣e5-mistral🛌🏻 by cloning this space. 🧬🔬🔍 Simp
13
  Join us : 🌟TeamTonic🌟 is always making cool demos! Join our active builder's🛠️community on 👻Discord: [![Let's build the future of AI together! 🚀🤖](https://discordapp.com/api/guilds/1109943800132010065/widget.png)](https://discord.gg/GWpVpekp) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Polytonic](https://github.com/tonic-ai) & contribute to 🌟 [Poly](https://github.com/tonic-ai/poly)
14
  """
15
 
 
 
16
  def last_token_pool(last_hidden_states: Tensor, attention_mask: Tensor) -> Tensor:
17
  left_padding = (attention_mask[:, -1].sum() == attention_mask.shape[0])
18
  if left_padding:
@@ -28,6 +30,9 @@ def get_detailed_instruct(task_description: str, query: str) -> str:
28
 
29
  @spaces.GPU
30
  def compute_embeddings(*input_texts):
 
 
 
31
  tokenizer = AutoTokenizer.from_pretrained('intfloat/e5-mistral-7b-instruct')
32
  model = AutoModel.from_pretrained('intfloat/e5-mistral-7b-instruct')
33
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
 
13
  Join us : 🌟TeamTonic🌟 is always making cool demos! Join our active builder's🛠️community on 👻Discord: [![Let's build the future of AI together! 🚀🤖](https://discordapp.com/api/guilds/1109943800132010065/widget.png)](https://discord.gg/GWpVpekp) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Polytonic](https://github.com/tonic-ai) & contribute to 🌟 [Poly](https://github.com/tonic-ai/poly)
14
  """
15
 
16
+ os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'max_split_size_mb:50'
17
+
18
  def last_token_pool(last_hidden_states: Tensor, attention_mask: Tensor) -> Tensor:
19
  left_padding = (attention_mask[:, -1].sum() == attention_mask.shape[0])
20
  if left_padding:
 
30
 
31
  @spaces.GPU
32
  def compute_embeddings(*input_texts):
33
+ torch.backends.cuda.matmul.allow_tf32 = True
34
+ torch.backends.cudnn.allow_tf32 = True
35
+ torch.backends.cudnn.benchmark = True
36
  tokenizer = AutoTokenizer.from_pretrained('intfloat/e5-mistral-7b-instruct')
37
  model = AutoModel.from_pretrained('intfloat/e5-mistral-7b-instruct')
38
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")