TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #425 · 20 апр.

Недавно делал быстрый прототип асинхронного приложения в котором требовалось вызывать много синхронного кода. Да, я знаю, что это не лучший дизайн, но нужно было быстрое решение на один процесс и без очередей. Поэтому я выполнял код в потоках. Выглядело это примерно так: from fastapi.concurrency import run_in_threadpool async def execute(data: DataRequest) -> DataResponse: try: result = await run_in_threadpool(sync_function, data) return DataResponse(data=result) except Exception as e: return DataResponse( error=str(e), success=False, ) В общем работает нормально. Для всех вызовов под капотом используется общий тредпул, всё работает предсказуемо. Но потребовалось изменить количество запускаемых в пуле потоков (по умолчанию создается 40 воркеров). Так как дело происходит с FastAPI, делается это через lifespan используя настройки anyio: import anyio @asynccontextmanager async def lifespan(app: FastAPI): limiter = anyio.to_thread.current_default_thread_limiter() limiter.total_tokens = 100 yield # если вдруг нужно вернуть обратно limiter.total_tokens = 40 Зачем менять количество воркеров? - уменьшить, если оперативки мало (один тред занимает ~8мб) - увеличить чтобы выдержать нагрузку Если есть предложения получше при тех же вводных - предлагайте😉 #async

Hashtags

Резултати

Пронајдени 1 слични објави

Пребарај: #chinesetech

当前筛选 #chinesetech清除筛选
AI & Law

@ai_and_law · Post #147 · 25.10.2023 г., 07:04

Proposed Chinese AI Safety Standards: A Closer Look Hey there, AI & Law community! On October 11, the National Information Security Standardization Technical Committee in China released a draft document outlining precise regulations for evaluating generative AI models. Unlike the often vague AI regulations, this document provides a clear blueprint for compliance. This standards proposal sets forth rigorous criteria for assessing AI data sources and their content. The document covers topics like training data diversity, moderation, and prohibited content. It emphasizes the need for diversified training corpora and the assessment of data quality. If more than 5% of data is "illegal and negative information," the corpus is flagged for future training. The proposal also suggests that AI companies employ moderators to enhance generated content quality, aligning with national policies and third-party complaints. This implies a potential expansion of the human-driven moderation and censorship workforce in the AI era. Companies are tasked with identifying hundreds of keywords for flagging unsafe or banned content, with separate categories for political and discriminative content. They must also generate more than 2,000 prompts, ensuring fewer than 10% of responses breach the rules. Interestingly, the document encourages subtler censorship measures, such as not refusing to answer sensitive prompts but allowing AI models to respond to specific, non-sensitive inquiries. It's crucial to clarify that these standards are not laws, and non-compliance doesn't result in penalties. However, proposals like these can significantly influence future regulations or work alongside them. The standards receive input from tech experts hired by companies, giving corporations like Huawei, Alibaba, and Tencent a say in shaping these regulations. Their influence could have far-reaching implications for the global AI industry and how AI technologies are regulated worldwide. #AISafety#AIRegulations#GenerativeAI#ContentModeration#ChineseTech#AIInfluence#GlobalAI