Telegram Group & Telegram Channel
Сделал вчера неочевидный баг в простом коде и какое-то время тупил, это ли не повод оставить задачку для уважаемых подписчиков?

Задача такая: из некоторого списка тегов отбираем наиболее важные по словарю рангов, формируем промпт и отправляем в модель. Что не так с этим кодом?

import typing as t


def predict_from_tags(model: BertModel, tags: t.Sequence[str]):
prompt = prompt_from_tags(tags, model.tag_ranks)
return model.predict(prompt)


def prompt_from_tags(tags: t.Sequence[str],
tag_ranks: t.Dict[str, float],
max_tags: int = 20,
allow_duplicates: bool = False,
) -> str:

if not allow_duplicates:
tags = list(set(tags))

sorted_tags = sorted(tags, key=lambda x: tag_ranks.get(x, float("inf")))
return " ".join(sorted_tags[:max_tags])

Автор первого правильного ответа в комментариях не получит ничего, кроме респекта от таких же любопытных, которым зачем-то интересно просто так искать баги в чужом коде.



group-telegram.com/partially_unsupervised/185
Create:
Last Update:

Сделал вчера неочевидный баг в простом коде и какое-то время тупил, это ли не повод оставить задачку для уважаемых подписчиков?

Задача такая: из некоторого списка тегов отбираем наиболее важные по словарю рангов, формируем промпт и отправляем в модель. Что не так с этим кодом?

import typing as t


def predict_from_tags(model: BertModel, tags: t.Sequence[str]):
prompt = prompt_from_tags(tags, model.tag_ranks)
return model.predict(prompt)


def prompt_from_tags(tags: t.Sequence[str],
tag_ranks: t.Dict[str, float],
max_tags: int = 20,
allow_duplicates: bool = False,
) -> str:

if not allow_duplicates:
tags = list(set(tags))

sorted_tags = sorted(tags, key=lambda x: tag_ranks.get(x, float("inf")))
return " ".join(sorted_tags[:max_tags])

Автор первого правильного ответа в комментариях не получит ничего, кроме респекта от таких же любопытных, которым зачем-то интересно просто так искать баги в чужом коде.

BY partially unsupervised


Warning: Undefined variable $i in /var/www/group-telegram/post.php on line 260

Share with your friend now:
group-telegram.com/partially_unsupervised/185

View MORE
Open in Telegram


Telegram | DID YOU KNOW?

Date: |

Some privacy experts say Telegram is not secure enough The Securities and Exchange Board of India (Sebi) had carried out a similar exercise in 2017 in a matter related to circulation of messages through WhatsApp. Russians and Ukrainians are both prolific users of Telegram. They rely on the app for channels that act as newsfeeds, group chats (both public and private), and one-to-one communication. Since the Russian invasion of Ukraine, Telegram has remained an important lifeline for both Russians and Ukrainians, as a way of staying aware of the latest news and keeping in touch with loved ones. WhatsApp, a rival messaging platform, introduced some measures to counter disinformation when Covid-19 was first sweeping the world. These entities are reportedly operating nine Telegram channels with more than five million subscribers to whom they were making recommendations on selected listed scrips. Such recommendations induced the investors to deal in the said scrips, thereby creating artificial volume and price rise.
from us


Telegram partially unsupervised
FROM American