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: |

Individual messages can be fully encrypted. But the user has to turn on that function. It's not automatic, as it is on Signal and WhatsApp. Oh no. There’s a certain degree of myth-making around what exactly went on, so take everything that follows lightly. Telegram was originally launched as a side project by the Durov brothers, with Nikolai handling the coding and Pavel as CEO, while both were at VK. Asked about its stance on disinformation, Telegram spokesperson Remi Vaughn told AFP: "As noted by our CEO, the sheer volume of information being shared on channels makes it extremely difficult to verify, so it's important that users double-check what they read." The fake Zelenskiy account reached 20,000 followers on Telegram before it was shut down, a remedial action that experts say is all too rare. To that end, when files are actively downloading, a new icon now appears in the Search bar that users can tap to view and manage downloads, pause and resume all downloads or just individual items, and select one to increase its priority or view it in a chat.
from us


Telegram partially unsupervised
FROM American