NYC Council Chief Data Scientist Deploys In-House AI for Legislation

RAG, from Theory to Implementation with New York City Council — Ai4

Ai4

New York City Council uses open-source vector embeddings and local LLMs to eliminate duplicate legislative submissions and automate municipal operations.

AI-assisted summary of RAG, from Theory to Implementation with New York City Council — original source. Check the original for full context.

Source published:

Detailed notes

## Background This video was published on YouTube by Ai4 on August 18, 2026. According to the page description, Alaa Moussawi, Chief Data Scientist at the New York City Council, presents the design, open-source hardware and software development, and on-premises deployment of a locally hosted Retrieval-Augmented Generation (RAG) LLM system within a local government organization.

## TL;DR Alaa Moussawi discusses how the New York City Council's in-house technical team leverages open-source data science and software engineering to modernize legislative workflows and support evidence-based policymaking. He traces the evolution of their internal tools from a 2018 Word2Vec-powered duplicate proposal checker to modern vector embeddings and semantic search systems. The talk highlights practical operational frameworks, data management practices, and technical methodologies for implementing secure, locally hosted RAG architectures in public sector environments.

## Atmosphere & style The presentation is pragmatic, technical, and lighthearted, opening with humor to engage the audience before diving into deep technical topics. Moussawi delivers the material in an approachable, grounded manner, drawing directly on his eight years of experience building municipal tech systems. The talk balances complex concepts like high-dimensional vector math with down-to-earth real-world problem solving, making it feel like an authentic, behind-the-scenes look at engineering in local government.

## Key takeaways - [00:04](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=4s) Alaa Moussawi serves as Chief Data Scientist for the New York City Council, managing in-house software engineering and data science teams to modernize legislative processes. - [00:04](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=4s) The NYC Council relies strictly on open-source tooling to automate administrative workflows and support evidence-based policymaking. - [02:14](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=134s) Before launching AI projects, organizations must evaluate technology maturity, data accessibility, user value, and operational constraints. - [02:14](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=134s) In 2018, the NYC Council built its first production ML tool, the Duplicate Checker, to identify overlapping legislative proposals submitted by 51 council members. - [02:14](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=134s) The original Duplicate Checker utilized 2013 Word2Vec embeddings to compute similarity rankings in 5 to 10 seconds, drastically reducing manual review errors. - [05:07](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=307s) Vector embeddings convert text into lists of numbers representing coordinates in high-dimensional vector spaces (spanning 1,000 to 8,000 dimensions). - [05:07](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=307s) High-dimensional vector dimensions represent learned semantic features discovered by neural networks, allowing mathematical operations on concepts. - [05:07](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=307s) Semantic vector arithmetic (such as 'royalty' plus 'woman' equalling 'queen') illustrates how spatial proximity maps conceptual relationships.

## Detailed walkthrough Here is a detailed, faithful walkthrough of the presentation based on the transcript:

[00:04](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=4s) Introduction and the Dual Mission at New York City Council

Alaa Moussawi (who also introduces himself as Al) opens the presentation by setting a lighthearted tone, hoping the audience will stay awake during a deep dive into Retrieval-Augmented Generation (RAG). He serves as the Chief Data Scientist for the New York City Council—the legislative branch of New York City government responsible for passing local laws and approving the municipal budget. Over his eight-year tenure, Moussawi has assembled and managed two distinct in-house technical teams: a data science team and a software engineering team. Together, they build open-source tools designed to modernize how the council interacts with data.

On the data science side, his team focuses on making the legislative process more evidence-based through statistical analysis. On the software engineering side, they develop internal platforms to manage everyday operations and automate workflows. Moussawi highlights that the intersection between these two disciplines—fact-based analytical rigor and process automation—is precisely### Introduction and the Dual Mission at the NYC Council

Alaa Moussawi (who also goes by Al) opens his presentation with a quick joke hoping everyone stays awake as he jumps into the details of Retrieval-Augmented Generation (RAG). As Chief Data Scientist for the New York City Council—the legislative branch tasked with passing city laws and negotiating municipal budgets—Moussawi reflects on his eight-year tenure building an in-house team of software engineers and data scientists from the ground up. The team operates strictly around open-source tooling, aiming to systematically modernize how the local government leverages data.

His organization bridges two distinct operational thrusts. On the data science side, the focus is making the legislative process strictly evidence-driven through statistical analyses. On the software development side, the goal is automating daily administrative workflows. The intersection of these two areas creates the sweet spot where artificial intelligence can genuinely augment public sector operations.

- **Role:** Chief Data Scientist, New York City Council (8+ years building the tech team). - **Legislative Mandate:** The NYC Council consists of 51 elected officials handling municipal laws and city budgets. - **Core Strategy:** In-house development using open-source tools to automate processes and enable evidence-based policymaking.

---

[02:14](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=134s) The Philosophy of Project Evaluation & The 2018 Duplicate Checker

Before launching any AI project, Moussawi emphasizes starting with purpose and clear intention. Teams must verify that the underlying technology is mature enough, that necessary data is accessible, and that the final output provides tangible value to end-users within realistic operational constraints.

To demonstrate these fundamentals, he steps back to 2018—prior to the modern generative AI boom—when his team built their first production machine learning tool: the **Duplicate Checker**. Every term, 51 council members submit tens of thousands of legislative proposals through custom in-house software. Because the legal team cannot draft every single idea, staff must quickly conduct a duplicate search to confirm which council member originally submitted a concept.

``` +-------------------------------------------------------------------+ | NYC COUNCIL LEGISLATIVE WORKFLOW | | | | 51 Elected Members ---> 10,000s Proposals ---> In-House App | | | | | v | | Duplicate Search | +-------------------------------------------------------------------+ ```

- **Problem:** Council members submit overlapping ideas expressed in vastly different phrasing, making human cross-referencing tedious and error-prone. - **2018 Baseline:** Implemented using Google's **Word2Vec** (2013 technology) to generate word embeddings. - **Performance:** Took 5 to 10 seconds to generate similarity rankings—significantly faster than manual review, helping reduce costly legislative errors.

---

[05:07](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=307s) Demystifying Vector Embeddings

Moussawi simplifies vector embeddings, demystifying the mathematical concepts behind modern AI models. At its core, an embedding is just a list of numbers (a vector) representing a specific coordinate in a high-dimensional space. While human visual intuition is limited to two or three dimensions, computer vector spaces regularly span 1,000 to 8,000 dimensions. Each dimension represents a learned feature deduced by a neural network.

To illustrate spatial math, he uses a classic semantic vector example: adding the vector for "woman" to the vector for "royalty" lands near the coordinate for "queen". Subtracting "royalty" from "queen" yields "woman" once again. While modern systems embed entire sentences using more sophisticated methods, Moussawi's early duplicate

## Notable quotes > [00:04](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=4s) hoping everyone stays awake as he jumps into the details of Retrieval-Augmented Generation (RAG) — Alaa Moussawi

## Mentioned Alaa Moussawi, Al, New York City Council, Retrieval-Augmented Generation, RAG, Google, Word2Vec

## Video description Alaa Moussawi - Chief Data Scientist, New York City Council

Are you curious to see a full deployment, from nuts and bolts (open source) to delivery? This presentation details the design and deployment of a locally hosted, open-source LLM within a government organization, from ordering individual parts and building a server by hand, to developing the software and integrating it into existing systems. It covers LLM fundamentals, an overview of Retrieval-Augmented Generation (RAG), and operational best practices, followed by a practical discussion of secure, on-premises implementation. Attend this talk to see the full picture!

[Source](https://www.youtube.com/watch?v=2rLb8VOxJG4)

中文简报

纽约市议会首席数据科学家部署内部AI推进立法 纽约市议会利用开源向量嵌入与本地大语言模型消除重复立法提案,并实现市政业务自动化。 Alaa Moussawi 探讨了纽约市议会内部技术团队如何利用开源数据科学与软件工程推进立法工作流程现代化,并为实证决策提供支持。他回顾了内部工具的发展历程,从2018年基于 Word2Vec 的重复提案检查工具,逐步演变为现代向量嵌入与语义搜索系统。该演讲重点介绍了在公共部门环境中部署安全、本地托管的 RAG 架构的实用操作框架、数据管理实践以及技术方法。 纽约市议会首席数据科学家 Alaa Moussawi 介绍了其团队如何坚持采用开源工具,将数据科学与软件工程相结合,以支持循证立法决策并自动化市政日常工作流程。 (0:04) 团队在 2018 年构建了首个生产级机器学习工具 Duplicate Checker,用以识别 51 位市议员提交的海量立法提案中是否存在内容重叠。 (2:14) 早期的 Duplicate Checker 采用 Word2Vec 词嵌入技术在 5 到 10 秒内计算文本相似度排序,显著降低了人工交叉比对的错误率与时间成本。 (2:14) 向量嵌入将文本转化为高维空间(通常为 1,000 至 8,000 维)中的坐标,通过空间维度的数学运算实现对语义和概念关系的精准表达。 (5:07)

Reading summary

Alaa Moussawi, Chief Data Scientist for the New York City Council, outlines how the municipal legislature combines data science and in-house software engineering to modernize legislative workflows through natural language processing and retrieval-augmented systems. Municipal Mandate and Technical Strategy (0:04) The New York City Council operates as the city's legislative branch, comprising 51 elected officials tasked with negotiating municipal budgets and enacting local laws. During his eight-year tenure, Moussawi established two internal technical groups—a data science team focused on evidence-based legislative analysis and a software engineering team dedicated to operational workflow automation. The council relies strictly on in-house development and open-source tooling, targeting intersections where automated systems can support public sector operations without external vendor lock-in. Pragmatic Project Evaluation and the 2018 Baseline (2:14) Moussawi argues that deploying machine learning in government requires confirming technological maturity, data accessibility, and clear operational value before implementation. To illustrate this discipline, he points to the council's 2018 'Duplicate Checker,' an internal tool created prior to generative AI to manage tens of thousands of legislative proposals submitted each term. Because council members frequently submit overlapping policy concepts using divergent phrasing, staff required an automated mechanism to confirm submission priority. Semantic Search via Vector Embeddings (5:07) The 2018 Duplicate Checker relied on Google's 2013 Word2Vec architecture to convert text into vector embeddings—numerical coordinates positioned across high-dimensional feature spaces typically ranging from 1,000 to 8,000 dimensions in modern systems. By conducting spatial mathematics, such as the semantic relationship where 'woman' combined with 'royalty' maps near 'queen,' the model compared proposal semantics rather than exact keyword matches. The system delivered ranked similarity comparisons within 5 to 10 seconds, cutting manual review time and reducing drafting conflicts among legal staff. The presentation notes cut off while transitioning from early word-level embeddings to modern sentence-level architectures, leaving the technical details of the council's current Retrieval-Augmented Generation implementation unspecified.

精炼阅读摘要

纽约市议会首席数据科学家阿莱·穆萨维(Alaa Moussawi)阐述了在地方立法机构应用人工智能的核心路径:通过将统计分析的严谨性与开源软件工程相结合,公共部门能够在严守业务约束的前提下,有效推进立法流程的证据驱动与行政自动化。 议会数字化定位与项目评估标准 (0:04) 穆萨维回顾了其在纽约市议会任职超过八年期间从零组建技术团队的经历。纽约市议会作为地方立法分支,由51位民选议员组成,核心职责涵盖地方法律制定与市政预算审批。在此架构下,技术部门划分为数据科学与软件工程两支团队:前者运用统计分析方法促建立法过程转向实证驱动,后者则自主开发开源内部平台以实现日常行政运营自动化。穆萨维强调,数据实证与流程自动化的交汇点,正是人工智能有效增强公共部门效能的关键切入点。 在启动技术项目前,穆萨维主张必须确立审慎的立项评估标准,防止脱离实际业务。团队在立项前需系统核验三项基本前提:第一,底层算法与技术本身已足够成熟;第二,业务所需的数据具备实际可获取性;第三,最终交付的功能必须能在现实的操作约束下,为终端用户带来切实可衡量的应用价值。 早期立法查重系统的落地与实践 (2:14) 在生成式人工智能普及之前,该团队于2018年落地了首个投入生产环境的机器学习工具——立法提案“查重器”(Duplicate Checker)。在每个立法任期内,51位议员会通过自研内部软件提交数万份立法构想。由于法务起草团队资源有限,无法逐一编写所有文本,工作人员必须快速判定某项创议最初由哪位议员提出。然而,不同议员经常使用差异巨大的措辞表达相同或高度重叠的构想,导致人工交叉核对极为繁琐且容易出错。 为化解此瓶颈,团队采用谷歌于2013年发布的Word2Vec技术生成词嵌入,用于捕捉词汇语义。该系统将相似度排名的生成时间缩短至5到10秒,相比传统的人工审查大幅提升了处理速度,有效降低了昂贵且容易引发争议的立法重复起草与归属失误。 向量嵌入的数学原理与空间计算 (5:07) 穆萨维对现代人工智能模型底层的“向量嵌入”(Vector Embeddings)进行了数学机制解析。向量嵌入的本质是代表高维空间中特定坐标的一组数字列表。人类视觉直觉通常局限于两维或三维物理空间,而计算机所构建的语义向量空间维度通常在1,000到8,000维之间,每一个维度均对应神经网络通过学习所提取出的特定特征。 穆萨维借助经典的语义空间运算展示了这一机制:将代表“女性”(woman)的向量加上代表“皇室”(royalty)的向量,在空间坐标上会极其接近“女王”(queen);反之,从“女王”向量中减去“皇室”向量,则会重新定位回“女性”坐标。穆萨维指出,尽管现代系统已发展为针对完整句子的复杂嵌入,但空间向量映射依然是让机器理解语义相似性的基础原理。 穆萨维通过2018年的查重案例证明,基于词嵌入的开源工具能够切实缓解公共部门的文本比对瓶颈;但本次演讲记录在由底层向量概念向现代检索增强生成(RAG)工程落地的过渡阶段中断,现代RAG架构如何完整融入当前议会工作流的具体方案仍待后续阐述。

Detailed notes — zh

## Background 本内容由 YouTube 频道 Ai4 于 2026 年 8 月 18 日发布,主讲人为纽约市议会(New York City Council)首席数据科学家 Alaa Moussawi。视频详细介绍了如何在政府机构内部从零搭建硬件、采用全开源技术栈实现本地化私有部署,并落地大语言模型(LLM)与检索增强生成(RAG)系统。 ## TL;DR 演讲首先回顾了纽约市议会自 2018 年利用 Word2Vec 开发立法“提案查重工具”的实践,阐明了向量嵌入的几何原理与 AI 决策边界。随后,主讲人梳理了从 RNN、LSTM 到 Transformer 的演进史,指出大模型本质上仍是基于统计概率的“下一个 Token 预测器”,其繁荣得益于缩放定律。最后,分享详细拆解了市议会如何通过句子级切分、向量召回与段落上下文还原构建本地私有化 RAG 架构,在确保数据安全的同时彻底杜绝幻觉。 ## Atmosphere & style 主讲人 Alaa Moussawi 风格幽默风趣、接地气且坦诚直率,常以自嘲打破技术讲座的枯燥感。整场演讲兼具深厚的工程实战底蕴与严谨的理性思辨,在拆解底层算法原理时化繁为简、生动具象。从早期手工攒机的硬核探索到对当代 AI “表面智能”的冷静祛魅,现场氛围既务实沉稳又充满技术启发性。 ## Key takeaways - [00:04](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=4s) 纽约市议会数据科学与软件团队坚持全开源与自主研发路线,通过统计建模提供循证支持,并搭建政务系统落地自动化。 - [01:33](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=93s) 开展 AI 项目需严格评估目标可行性、技术成熟度、数据可得性及用户收益四项原则,避免盲目跟风。 - [01:33](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=93s) 市议会早期开发提案查重工具(Duplicate Checker),以应对 51 位议员每年提出的上万条表述各异的立法构想并保障提案优先权。 - [04:27](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=267s) 向量嵌入在数学上是高维空间的坐标,通过向量加减与几何距离计算(如勾股定理、余弦相似度)能够实现语义相似度匹配。 - [09:16](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=556s) 立法构想是否实质重复缺乏客观标准(Ground Truth),因此 AI 只能作为推荐与辅助决策工具,定夺权必须留在专业法务人员手中。 - [10:22](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=622s) 从 RNN、LSTM 到 Transformer 架构,语言模型本质上始终是自回归的“下一个 Token 预测器”,并不具备高级逻辑规划能力。 - [14:08](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=848s) 大语言模型的流畅表达源于海量预训练数据的统计模式拟合,而非人类意义上先有概念再用语言表达的“真正理解”。 - [16:01](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=961s) 幂律缩放定律(Power Law Scaling)确立了算力、数据量、参数量与模型性能之间的对数线性收益,推动了大规模算力投资与开源模型繁荣。 - [18:56](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=1136s) 纽约市议会采用本地私有化部署(On-Prem)开源模型,在确保敏感法律数据安全的同时将日常运营成本降至极低。 - [18:56](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=1136s) 本地 RAG 架构采用句子级切分生成向量以保证语义密度,检索召回时再扩展至段落上下文,并配合严格 Prompt 杜绝幻觉。 ## Detailed walkthrough ### [00:04](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=4s) 纽约市议会的立法职能与数据科学团队架构 主讲人 Alaa Moussawi(大家都叫他 Al)以幽默轻松的口吻开场,打趣说希望大家在听关于 RAG(检索增强生成)的技术分享时能“努力保持清醒”。Alaa 担任纽约市议会(New York City Council)的首席数据科学家。他解释道,市议会作为纽约市政府的立法分支机构,核心职能是审议通过纽约市的法律法规并制定全市的财政预算。 在市议会任职的八年多时间里,Alaa 一手组建并带领着两支核心技术团队:一支数据科学家团队和一支软件工程师团队。团队内部坚持全栈式自研与开源路线,不仅逐步培养起内部技术实力,也自下而上地改变了市议会使用和理解数据的方式。具体而言,数据科学团队致力于让立法过程更加遵循循证原则(evidence-driven)和客观事实,通过统计学建模与定量分析为重大立法决策提供事实依据;软件开发团队则负责搭建处理日常政务流程的业务系统,在各个环节落地自动化。正是在数据科学与软件工程的交叉地带,孕育出了将人工智能应用于真实政务场景的契机。 - **机构定位**:纽约市议会为立法机构,负责纽约市的法案表决与财政预算审批。 - **团队战略**:建立全开源(Open-Source)、完全自主研发(In-House)的工程与算法能力。 - **业务分工**: - 数据科学:利用统计分析为立法提供事实支撑与循证支持。 - 软件工程:承载日常业务工作流,推进全流程系统自动化。 --- ### [01:33](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=93s) AI 项目落地准则与“查重工具”的业务挑战 Alaa 明确了本次分享的核心框架:首先以向量嵌入(Vector Embeddings)的基本原理切入,剖析其局限性及 AI 对市议会工作流程的改造;接着回顾 AI 演进史,认清其能力与缺陷;最后展示市议会如何利用开源自建 AI 为员工赋能。 在开展任何技术项目之前,团队必须审慎评估四项核心原则: 1. **目标与可行性**:项目必须带着明确的目的与意图开展,确保产出在业务上具有现实可行性; 2. **技术成熟度**:必须确认现有技术是否足以支撑该目标,而非盲目跟风; 3. **数据可得性**:是否具备端到端落地所需的高质量数据; 4. **用户收益**:在现实技术局限与边界条件下,最终交付的产品能否切实减轻终端用户负担。 以此为背景,Alaa 回溯到了生成式 AI 大爆发前的 2018 年,当时团队为市议会开发了首个机器学习系统——“提案查重工具”(Duplicate Checker)。在纽约市议会,51 位民选议员每年会提出数以万计的立法构想。市议会无力将成千上万的想法全部起草为成文法案,必须由自研业务软件介入流转。其中最关键的一步是查重:判断哪位议员最先提出该倡议,以保障立法提案的优先权。然而,不同的议员往往会用截然不同的辞藻和表述方式去阐述同一个核心立法构想,这给传统文本比对和人工查验带来了巨大挑战。 ```mermaid flowchart TD accTitle: 提案查重业务流程 subgraph Input ["提案输入阶段"] A["51 位民选市议员"] --> B["提出上万条立法构想"] B --> C["自研立法业务系统"] end subgraph Process ["查重与比对阶段"] C --> D["语义查重检索系统 (Duplicate Checker)"] D --> E["Word2Vec 词向量计算与余弦相似度匹配"] end subgraph Review ["人工决策阶段"] E --> F["输出相似度推荐排序列表 (耗时 5~10 秒)"] F --> G["立法律师介入人工终审判断"] end ``` --- ### [04:27](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=267s) 向量嵌入的数学原理:空间几何与语义运算 面对文本表述千差万别的难题,团队在 2018 年的第一版查重系统中采用了 Google 于 2013 年开源的 Word2Vec 算法来生成词向量(Word Embeddings)。虽然系统计算并生成一份相似度候选排序需要花上 5 到 10 秒钟,以现在的眼光看略显笨拙,但在当时已比人工翻卷宗快得多,大幅提升了法务人员的效率,显著降低了在立法立项环节出现优先权错判的代价。 Alaa 进而用通俗且具象的语言阐述了向量嵌入的本质:它在数学上不过是一串数字(列表),代表高维空间中的一个坐标位置。二维平面上是一个点,三维空间中是一个立体坐标,而到了深度学习中,它可能是包含 1,000、4,000 甚至 8,000 个浮点数的超高维坐标。神经网络在隐空间中自动推导这些维度的数值,单个维度可能融合了诸如“聪明程度”、“松脆质感”等人类语言无法完全具象解释的概念特征,而整组数字构成的空间向量,就凝练出了词汇的语义特征。 Alaa 列举了经典的自然语言处理案例:假设在二维坐标系中玩猜词游戏,输入“女性”(Woman)的向量与“王室/皇权”(Royalty)的向量,两者相加: $$\vec{v}_{\text{woman}} + \vec{v}_{\text{royalty}} \approx \vec{v}_{\text{queen}}$$ 模型推导出的空间坐标直指“女王”(Queen);反过来,从“女王”向量中减去“皇权”向量,就还原出了“女性”向量。在大语言模型中,机器无法直接理解字符串,第一步都必须将文字映射为这类向量。在最初的查重工具中,Alaa 采用了一种朴素而有效的方法:将整句文本中各个单词的向量直接相加求和,得到代表该提案构想的整体句子向量。接着,只要运用初中数学中的勾股定理(欧氏距离或余弦距离公式),将其向高维空间推导,就能计算两个句子向量之间的距离。几何距离越近,说明语义相似度越高。 --- ### [09:16](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=556s) AI 的边界:为何算法永远无法取代人工终审 虽然数学逻辑非常自洽,但 Alaa 重点强调了一个产品与制度设计的核心界限:查重工具从不直接给出具有法律效力的判定,它仅仅是一个“推荐系统”。 其根本原因在于,“两个立法构想是否构成实质重复”本质上是一项极为主观的法律定性。即便是市议会法务部门资深的专业律师们坐在一起研判,也常常就两项提议是否雷同争论不休、难以达成一致。人类法务专家在主观判断上尚且无法得出百分之百确定性的结论,寄希望于 AI 给出盖棺定论的判定无异于痴人说梦。一旦缺乏评估结果的确定性标准(Ground Truth),机器就绝对不可能做出可靠的裁决。因此,团队将其严格限制在决策辅助与排序推荐层面,最终把定夺权牢牢留在人类专业人员手中。 - **主观性困境**:不同律师对法案条款是否重复存在主观分歧,缺乏客观判定标准。 - **系统定位**:提供 top-k 相似候选以供参考,避免系统越权做出确定性归论。 - **工程哲学**:人类无法达成确定性共识的任务,不应强求算法实现全自动闭环。 --- ### [10:22](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=622s) 从 RNN 到 Transformer:语言模型本质只是“下一个 Token 预测器” Alaa 将话题引向近年来的技术演化史,并抛出一个鲜明的论断:虽然自己是 AI 的狂热爱好者,但他仍会坦率地称现阶段的 AI 是“愚蠢的”(stupid)。十年前的生成模型连基本的摘要抽取都难以可靠胜任,而如今的 AI 仿佛无所不能——可以充当心理咨询师、为工程师 Debug 找漏洞、切换各种人设,甚至写出押韵工整优美的诗歌歌曲。这一飞跃建立在三次关键架构演进之上: 1. **循环神经网络(RNN)**:首次引入反馈机制(Feedback Loop),但存在严重的梯度消失(Vanishing Gradient)问题,难以捕捉长距离上下文; 2. **长短期记忆网络(LSTM, 1997 年)**:通过门控单元有效解决了梯度消失问题,能够记忆输入序列中较早出现的单词及其相对语序,但依旧局限于仅能根据过往序列预测下一个最具可能性的单词; 3. **Transformer 架构与注意力机制(Attention, 2017 年)**:使模型能全局审视序列中所有历史词汇的位置,动态衡量各个词对于生成当前内容的重要权重,彻底解决了并行计算与超长依赖问题。 然而 Alaa 强调,撕下“智慧”的假象,无论是早期的 RNN、LSTM,还是当今最先进的前沿大模型(不管是 Fable、Mythos 还是 Claude Opus 级别的模型),底层的计算范式从始至终未曾改变——它们本质上都是“下一个 Token 预测器”(Next-token prediction)。一个 Token 大致相当于一个词或词根(例如 runner 由 `run` 和 `ner` 两个 Token 组成,而 chicken 自身是一个 Token)。 当用户向模型提问“*Why did the chicken cross the road?*”(为什么小鸡要过马路?)时,模型唯一的底层行为是计算下一个最可能的单字概率。它吐出“*The*”后,第一步计算便已终止;随后模型将原始提问连同刚生成的“*The*”重新拼装为一个新的输入序列回传给自己,预测出下一个词“*chicken*”;接着再把“*... The chicken*”喂回自身,预测出“*crossed*”;如此周而复始、不断自回归迭代循环(“Rinse, repeat, recycle”)。Alaa 感叹,这套自 1980 年代起就确立的基础范式至今仍在沿用,科学家们正是用这种最朴素的自回归循环让机器“开门说话”。但这同时也意味着:模型在吐出当前词时,根本不知道自己未来几步后会说什么,其内部并没有完整的高级逻辑规划。 | 架构类型 | 标志性年份 | 核心技术机制 | 主要突破与局限 | |:--- |:--- |:--- |:--- | | **RNN** | 1980年代 | 环状反馈网络(Feedback Loop) | 引入记忆机制;存在梯度消失问题,无法长程记忆 | | **LSTM** | 1997年 | 门控机制(输入门、遗忘门、输出门) | 解决梯度消失问题;但依然是单向单步递推预测 | | **Transformer** | 2017年 | 自注意力机制(Self-Attention) | 实现全序列上下文权重动态关联;底层仍是自回归 Next-token 预测 | ### [14:08](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=848s) 大语言模型的本质:统计概率预测与“真正理解”的差异 大语言模型(LLM)在生成诸如“小鸡穿过了(the chicken crossed)”这样的短语时,它本身并不知道接下来一定会接“马路(the road)”。模型之所以能流畅输出,完全是因为在其训练阶段吞吐了海量数据——包括维基百科的每一个词条、数以万亿计的 Token。LLM 从这些训练数据中提炼出统计模式,从而能够极其逼真地预测序列中的下一个最可能 Token,以至于让人误以为它具备真正的理解力。 演讲者强调,这绝非人类意义上的“理解”。当人类在交流时,大脑中首先存在一个概念或想法,随后寻找词汇作为工具将该思想传递给听众;而 LLM 仅仅是在统计概率的驱动下预测下一个 Token。“它之所以学会了语法、说服力以及礼貌用语,纯粹是因为这些模式原本就存在于训练数据之中,仅此而已。” - **机制对比**:人类使用语言作为传递头脑中抽象概念的媒介,而 LLM 只是基于海量预训练数据拟合序列概率分布。 - **表面智能的来源**:语法的合规性、修辞逻辑和委婉语气的展现,均源自预训练数据中统计模式的内化沉淀。 --- ### [16:01](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=961s) 缩放定律的发现与算力狂潮 在 Transformer 架构问世后,学术界和工业界并未出现颠覆底层科学原理的全新突破,但大约在 2020 年左右,研究人员迎来了一项关键的科学认知——幂律缩放定律(Power Law Scaling)。研究表明,算力开销、数据集规模、模型参数量与模型性能之间存在着高度确定的对数线性关系(在对数坐标图上表现为持续向下的直线)。 这一发现确立了提升模型能力的明确路径:要么喂入更多数据,要么投入更多算力,要么扩大模型参数(例如从 Qwen 27B 到 LLaMA 70B,乃至数万亿参数的超大规模模型)。在 2020 年 ChatGPT 尚未问世、没人确信机器能真正开口震撼世界之前,正是这一科学结论促成了数以千万美元计的电费与算力设备投资。如今开源模型之所以能够紧追顶尖闭源模型,很大程度上也是这一缩放逻辑在大规模工程上的持续验证与效率优化。 ```mermaid flowchart TD accTitle: 模型性能的缩放定律维度 subgraph ScalingLaws ["缩放定律的三大核心要素 (Power Law Scaling)"] A["计算资源 (Compute)"] B["数据集规模 (Dataset Size)"] C["参数体量 (Model Parameters)"] end A --> D["模型性能持续提升<br/>(对数坐标呈线性收益)"] B --> D C --> D ``` - **缩放三大轴心**:计算资源(Compute)、训练数据量(Dataset Size)、模型参数规模(Parameters)。 - **工程飞轮**:由于性能收益高度可预测,数百万美元的电力与算力集群投资得以迅速铺开,直接催生了当下的生成式 AI 繁荣。 --- ### [18:56](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=1136s) 纽约市议会的 RAG 架构与本地化落地方案 回归到纽约市议会(New York City Council)的具体业务场景,团队出于安全与合规考虑选择了本地私有化部署(On-Premises)。除了前期采购 GPU 硬件的固定投入外,日常运行仅产生少量的电力成本,性价比极高。市议会的核心业务需求是盘活数十年沉淀下来的立法法律备忘录与研究档案:律师与政策分析师在起草新法案时,必须确保新立法与过往的历史调研及法律结论保持严谨一致。 为了实现这一目标,团队搭建了完整的检索增强生成(RAG)流水线。首先,系统将历史法律备忘录切分为句子粒度(Sentence Chunking),因为单个向量的语义容量与一个句子所承载的单一观点天然契合。随后,系统为每个句子生成向量嵌入(Vector Embeddings)并存入向量数据库。当业务人员提出查询时,系统同样将其转化为向量,执行相似度检索并命中 Top 5 至 Top 10 个最相关的句子;为了给大模型提供充足上下文,系统还会回溯抓取这些句子所处的完整段落。最后,将这些精准召回的上下文拼接入系统提示词,严厉约束 LLM “仅基于提供的文本作答,不得编造任何内容”,从而彻底杜绝幻觉。 ```mermaid flowchart TD accTitle: 纽约市议会本地 RAG 检索与生成流水线 subgraph DataIngestion ["离线数据索引阶段"] A["法律历史备忘录"] --> B["句子级文本切分 (Sentence Chunking)"] B --> C["生成向量嵌入 (Embeddings)"] C --> D[("本地向量数据库 (Vector DB)")] end subgraph QueryPipeline ["在线检索与生成阶段"] E["用户立法查询 (User Query)"] --> F["查询向量化"] F --> G["向量相似度检索 (Top 5-10)"] D -. 相似度匹配.-> G G --> H["回溯提取段落上下文 (Paragraph Context)"] H --> I["组合严谨 Prompt 约束<br/>'仅根据提供材料作答,严禁幻觉'"] I --> J["本地开源 LLM 推理生成"] end ``` - **部署形态**:全流程私有化本地托管(On-Prem),保障政府内部敏感法律数据的绝对安全与低运营成本。 - **切分策略(Chunking)**:以句子为核心单元进行向量化,匹配“一个向量对应一个核心概念”的最佳信息密度,检索后再扩展至段落上下文。 - **未来演进**:团队在完成初始硬件升级提速后,正进一步向模型上下文协议(MCP)智能体系统演进,以构建更强大的专业法务助手。 ## Notable quotes > [00:04](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=4s) 努力保持清醒 — Alaa Moussawi > [00:04](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=4s) 两支核心技术团队:一支数据科学家团队和一支软件工程师团队 — Alaa Moussawi > [00:04](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=4s) 让立法过程更加遵循循证原则(evidence-driven)和客观事实 — Alaa Moussawi > [04:27](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=267s) 女性(Woman)的向量与“王室/皇权”(Royalty)的向量,两者相加……模型推导出的空间坐标直指“女王”(Queen) — Alaa Moussawi > [09:16](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=556s) 查重工具从不直接给出具有法律效力的判定,它仅仅是一个“推荐系统” — Alaa Moussawi > [09:16](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=556s) 人类无法达成确定性共识的任务,不应强求算法实现全自动闭环 — Alaa Moussawi > [10:22](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=622s) 愚蠢的(stupid) — Alaa Moussawi > [10:22](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=622s) 底层计算范式从始至终未曾改变——它们本质上都是“下一个 Token 预测器” — Alaa Moussawi > [10:22](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=622s) Rinse, repeat, recycle — Alaa Moussawi > [14:08](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=848s) 它之所以学会了语法、说服力以及礼貌用语,纯粹是因为这些模式原本就存在于训练数据之中,仅此而已 — Alaa Moussawi > [18:56](https://www.youtube.com/watch?v=2rLb8VOxJG4&t=1136s) 仅基于提供的文本作答,不得编造任何内容 — Alaa Moussawi ## Mentioned Alaa Moussawi, 纽约市议会 (New York City Council), RAG (检索增强生成), Word2Vec, Google, RNN (循环神经网络), LSTM (长短期记忆网络), Transformer, Claude Opus, ChatGPT, Qwen 27B, LLaMA 70B, MCP (模型上下文协议) ## Video description Alaa Moussawi - Chief Data Scientist, New York City Council Are you curious to see a full deployment, from nuts and bolts (open source) to delivery? This presentation details the design and deployment of a locally hosted, open-source LLM within a government organization, from ordering individual parts and building a server by hand, to developing the software and integrating it into existing systems. It covers LLM fundamentals, an overview of Retrieval-Augmented Generation (RAG), and operational best practices, followed by a practical discussion of secure, on-premises implementation. Attend this talk to see the full picture! [Source](https://www.youtube.com/watch?v=2rLb8VOxJG4)

Source quotes

[0:04] Alaa Moussawi: 努力保持清醒 [0:04] Alaa Moussawi: 两支核心技术团队:一支数据科学家团队和一支软件工程师团队 [0:04] Alaa Moussawi: 让立法过程更加遵循循证原则(evidence-driven)和客观事实 [4:27] Alaa Moussawi: 女性(Woman)的向量与“王室/皇权”(Royalty)的向量,两者相加……模型推导出的空间坐标直指“女王”(Queen) [9:16] Alaa Moussawi: 查重工具从不直接给出具有法律效力的判定,它仅仅是一个“推荐系统” [9:16] Alaa Moussawi: 人类无法达成确定性共识的任务,不应强求算法实现全自动闭环 [10:22] Alaa Moussawi: 愚蠢的(stupid) [10:22] Alaa Moussawi: 底层计算范式从始至终未曾改变——它们本质上都是“下一个 Token 预测器” [10:22] Alaa Moussawi: Rinse, repeat, recycle [14:08] Alaa Moussawi: 它之所以学会了语法、说服力以及礼貌用语,纯粹是因为这些模式原本就存在于训练数据之中,仅此而已 [18:56] Alaa Moussawi: 仅基于提供的文本作答,不得编造任何内容

Source quotes

[0:04] Alaa Moussawi: hoping everyone stays awake as he jumps into the details of Retrieval-Augmented Generation (RAG)

Original transcript

[0:04] Hi, my name is Alatam Sawi or Al and  uh today we'll be talking about RAG um [0:12] and hopefully staying awake  as we do. All right. So, um, [0:17] yeah, as was mentioned, I am the chief data  scientist for the New York City Council, [0:22] which is the legislative branch  of the New York City government, [0:26] meaning that we pass the laws for New York City  and we pass the budget for New York City. Um, [0:31] and at the New York City Council, I I've been  there for a little over eight years. I run a [0:35] team of data scientists and a team of software  engineers that I've put together over the past [0:41] eight years building all sorts of capabilities  inhouse um developing everything we do open-source [0:48] uh you know building that skill set and slowly  transforming how the council interacts with data [0:56] in part by on the data science side making the  legislative process more fact-based and evidence- [1:02] driven and using statistical analyses to help  make decisions and then on the software side [1:10] by helping develop software that manages  everyday processes and automating things [1:16] uh left and right and in the space between  the two is where the opportunity for AI lives [1:23] and that is what I'll be  talking about today. Um so [1:33] I'll start off by motivating and  explaining the use of vector embeddings [1:38] uh looking at some of the limitations and  discussing how uh LLMs and AI have impacted [1:48] uh workflows at the New York City Council.  Then I'll walk through some history of how [1:54] AI has come to be at the point that it is at  today and so that we can better understand [2:00] its capabilities and its shortfalls. And finally  uh I'll explain how at the at the council we're [2:06] using AI to empower staff uh and try to explain  as many technical concepts as I can along the way. [2:14] So now before we dive into any project,  it's always good to make sure that we're [2:20] doing it with purpose and with intention and that  there's a feasible outcome at the end of the day. [2:28] You should also make sure that the necessary  technology exists and it's capable of doing [2:34] what you're trying to do and that you have access  to all the data necessary to do it. And finally, [2:42] that given the realistic constraints  and limitations of what you're doing, [2:47] the end product will be beneficial to the end  user. So, we're going to start off today's talk [2:54] with a model considered now by today's standards  to be very rudimentary, but one that's very [2:59] instructional and can get us to understand some  of the most basic concepts of machine learning, [3:05] which is a term I'll interchange with AI. Same  thing in my head. I apologize if you disagree. So [3:12] back in 2018 before the explosion of  generative AI was when we first built our [3:19] first machine learning application. It it's called  the duplicate checker. And so at the New York [3:24] City Council there's 51 elected officials. They  submit tens of thousands of ideas that they want [3:31] to become legislation. And they submit these  ideas into software that we've built inhouse. [3:37] and we can't draft tens of thousands  of ideas. So there's a whole process [3:43] that goes on and it's managed by the software.  And part of the process is performing what's [3:49] called a duplicate search. So you have to identify  which council member thought of the idea first. [3:56] And you can get similar ideas written with very  different words. And so you'll see why this is an [4:05] an example of something that's very well  suited for vector embeddings to handle. Um [4:12] and so this is something that is a  challenge for humans and for computers to do [4:18] um just because of the nature of it.  And so we had to take a stab at it. Um, [4:27] so the first implementation, and we're going  to get into exactly how all this works, [4:31] used Google's word, which was 2013 technology  for generating word embeddings. Um, [4:39] and it would take 5 or 10 seconds to  spit out a list of recommendations. [4:44] Now, similarity rankings. Now, that's a lot  faster than a human, but it's still slow. But [4:54] the point is that it can make the human a lot more  efficient, saving a lot of time and increasing uh [5:00] decreasing the likelihood of errors that are that  can be very costly in the legislative process. [5:07] And the key technology behind this is the vector  embedding. So what is a vector embedding you ask? [5:16] A vector embedding is simply a list of numbers.  That's it. It's called a vector in math [5:23] and it represents the position or a position in  a space. So it can in a three-dimensional space [5:33] it's a position right here. On a two-dimensional  space it'll be like somewhere on your flat screen. [5:39] Uh and it can be a bunch of numbers. It could  be like a thousand numbers. It could be 4,000 [5:44] 8,000 numbers. And each number in this vector,  this list of numbers holds some significance. So [5:54] we don't know, it's very difficult to figure  out what the significance is because the neural [5:58] network is deducing what the values are, but  it could be like a combination of things. It [6:04] could be like how intelligent and crunchy you  are. Like we're just making up random things. [6:09] And that could be one of the numbers. And then  all of them have their own specific meaning. [6:13] and then all of them coming together in  this vector space represent something. [6:19] So uh to get the point across let's consider the  vector for royal uh sorry the vector for woman [6:30] and the vector for royalty. And now  these are in two dimensions because [6:36] we only have two dimensions on the  screen in your computer. It lives in a [6:40] very highdimensional space, but  the same math extrapolates. So [6:46] if we add the vector for royalty to the vector for  woman, let's say we were playing the game taboo [6:53] and I said royalty and woman, you guys, what  would you guess? We queen Elizabeth maybe. [7:00] Uh, and yeah, exactly. That is what you get if you  build a good vector embedding model. it should be [7:08] able to deduce that relationship. So similarly, if  you take queen and you subtract royalty, you get [7:16] woman. Um, and this is the crucial technology that  was employed in the duplicate checker and it's [7:24] part of the basis of all large language models  because they have to first convert words into [7:32] numbers because machines don't understand just  words. Um, and so you use the full set of text [7:42] and you can train a model and it'll eventually  learn the relationships between words based on how [7:51] how close to each other they appear in in text  which is a pretty impressive thing. Now similarly [8:00] if you have the vector for the word  idea and the vector for the word whole [8:12] I can make something up because we make things  up. Now this is not how they do it in modern [8:18] LLMs but this is actually how I did it for this  example uh for the duplicate checker that I use. [8:25] You can just sum up the words for whole idea  and you get the vector for a a sentence. Now [8:32] whole idea this is not the way it's done in modern  systems but it's a way that you can do it. Uh [8:41] and then what can you do now? You have one  vector or one point in space for whole idea [8:48] and you have another vector or another point  in space for another sentence. you can measure [8:54] the distance between them. And  the closer these two vectors are, [9:01] the more similar they are. And measuring the  distance is literally as simple as the Pythagorean [9:07] theorem in two dimensions. And then you uh  extend it out into a higher dimensional space. [9:16] Now that said, one point I do want to emphasize  is that this duplicate checker doesn't provide any [9:23] final recommendations. And the most direct  explanation of why it doesn't is because [9:31] assessing whether two ideas are similar enough  to be considered duplicates of each other [9:37] is inherently subjective. attorneys within the  organization will disagree on whether two ideas [9:44] are duplicates of each other. And so if the  if the humans can't deterministically come to [9:51] a conclusion, then it's lost hope for the  AI. So it's a recommendation system. Um and [10:03] yeah, it has its limitations. So with no  deterministic way to evaluate the output, [10:09] a machine certainly never will. Um, and this  really has nothing to do with AI. This this [10:15] applies anywhere else as well. Anyway, that said,  I'm going to now pivot us slightly and I'm going [10:22] to take a moment to briefly go through the recent  history of developments in AI to motivate why even [10:29] though I am a huge fan of AI, I call it stupid.  So about a decade ago, we couldn't rely on Gen AI [10:38] to reliably take on tasks such as summarization,  which now we take for granted, and now it could [10:44] like it could be your therapist. It can debug your  code for you. It can develop whatever for you. [10:49] It can take on different personalities. It can  write you a really nice song that rhymes very [10:55] well. Um, and so how did we get here to this  amazing point? So the recurrent neural network [11:05] was the first to have a feedback loop but  it had a large set of issues which were [11:11] eventually resolved with the long shortterm  memory neural network architecture in 1997 [11:18] um which could remember words that came earlier in  a sequence and the order they came in. uh and it [11:26] it solved something called the vanishing gradient  problem that the recurrent neural networks had. [11:32] But then it also had its own issues um which  was that it was only predicting the next best [11:42] token given the previous sequence. And  then they came up with something called [11:48] the attention mechanism which you've probably  heard of and that was uh 2017. Um and so [11:58] it came up with something a little a little better  in that it could pay attention to the positions of [12:04] all the words in the past and it could understand  how important they were to generate the uh [12:13] the next token. Now, what's really important  to understand is all of these models, including [12:23] transformers, sorry, it was  transformers, that was 2017. Um, [12:30] they're all doing the same thing on the back end.  All these models are doing next token prediction. [12:37] That means that you feed them. By the way,  token is the same more or less as saying word. [12:44] Like runner is runer two tokens, but like  chicken is one token u so on and so forth. [12:52] So all these models you ask it why did  the chicken cross the road and all it does [12:58] is it and and all of the models we're  using today fable mythos opus whatever [13:05] they're just predicting the next most likely  token given a sequence of previous tokens. [13:12] So you ask it why did the chicken cross the road  the model predicts the word 'the' and it's done. [13:20] Then it takes all of that. Why did the chicken  cross the road? The It pumps it back into itself [13:24] and it predicts the word chicken. And then  it takes Why did the chicken cross the road? [13:28] The chicken pumps it back into itself. Crossed.  Repeat. Rinse. Repeat. Recycle. And that's because [13:35] that's the best way that scientists have thought  of to make a model talk. I mean, these models are [13:42] talking, which is wild. It's very impressive.  So, but the architecture of how they're talking [13:51] is very basic and it's based on the same  stuff that we've been using since the 80s. [13:58] And if you if you really understand that, you  should start to understand that when a model is [14:04] spitting out words or tokens, it doesn't know what  it's going to say in the future. So, it says the [14:08] chicken crossed. It has no idea that it's going to  say the chicken crossed the road. It's just saying [14:13] the chicken crossed because given all the data  that this that it's been trained on which now you [14:20] have like uh it's been trained on every Wikipedia  article all these like everything trillions of [14:26] tokens right that that's why the training data  is so important it's picked up these patterns [14:32] from all this training data and now it's able to  predict the next most likely token in the sequence [14:38] in such a convincing way that it seems seems to  understand what it's saying. But uh I would argue [14:49] that that is not true understanding. It's  just predicting a token in a sequence [14:55] given training data without any concept of what  it's saying. I right now am expressing an idea to [15:01] you with words and I'm finding the words to relay  that idea and you're understanding this concept [15:08] that I have in my head that I'm using words as  a tool to just transfer over to you right now. [15:15] That's not at all what LLM are doing. LLMs  are predicting the next most likely token [15:21] given a whole bunch of training data and that  is it. So the patterns and the training data [15:27] have been baked into them. So, it's learned  grammar and persuasion, how to speak politely [15:33] just because it was in the training data  and and that's all there is to it. Um so [15:43] yeah, now they get to the point of um transformers  and they're doing things a lot more efficiently [15:54] now than they were doing in the past. Um, [16:01] and so really in terms of like serious scientific  breakthroughs and progress since Transformers, [16:09] nothing I wouldn't say  anything has been like a crazy [16:14] breakthrough, but they came up they came to  some scientific realizations around 2020. And [16:28] so what they realized is that there's and this  is going to get a little complex but there's [16:33] a consistent power loss scaling between compute  this is in the wrong order compute data set size [16:44] and the number of parameters in your model and the  performance of your model. So this was like a 2020 [16:52] maybe Google paper. I'm not I'm forgetting.  But you see how there's a straight line even [16:57] though it's on a logged scale graph. The line  kept going down. So what they realized is [17:04] we can either train on more data. We can either  throw more compute power at it or we can train [17:16] uh a larger model with like you know how they  say llama 70B 70 billion parameters or like uh [17:23] quen 27b 27 bill. So you could just  make the model bigger, more neurons, [17:28] add more data or add more compute and you keep  getting smarter and smarter models. Now remember [17:33] in 2020 we didn't have chat GPT. Nobody knew that  these machines were going to actually like start [17:38] talking and they like blow our minds. But then  they convinced I don't know who they convinced [17:46] to dump a lot of money like millions of dollars  just on electricity and equipment to run and start [17:53] training these M. And then and then that's how we  got here. It was from dumping massive amounts of [17:59] first the scientific realization that we could  just dump massive amounts of money into these [18:07] computers with the current technology and it'll  just keep getting better and better and better [18:11] and then they did it. And then and then right now  like in my opinion like any advancements we see [18:17] um although this could be a contested opinion are  just because they're making this for the most part [18:22] this is not 100% true. they are doing some things  that are but like on the on the cutting edge like [18:27] you get all these open source models that are  now competing with the closed source models [18:31] that's just cuz they're like building models  that are their size 2.8 trillion parameters now [18:35] where we are um and so yeah that that was  it. So, we just made things more efficient [18:45] and we're still finding ways to make things more  efficient as we go and increasing the size. Um, [18:53] and so, all right, let's forget about  the history for a second and we're going [18:56] to go back to applications at the New York City  Council. So, at the New York City Council, we uh [19:02] we run [clears throat] our stuff locally and we  host it on prem. uh meaning that all the all we [19:10] pay is for the electricity consumption beyond  the initial cost of some RTX 5090s that we run. [19:18] Um and given the small size of the models  that we run, it's not so expensive. And [19:26] so what we wanted to do is we wanted to  utilize a vast repository of legal documents [19:33] uh that the New York City Council had. These are  documents that contain all of the legal findings [19:40] from the research that the attorneys and the  policy analysts have performed in the past [19:44] as they're drafting legislation because in the  future any legislation they draft needs to be [19:50] consistent with any of their findings from earlier  in time. And so I'm going to make this very quick [19:57] because I've ran a little over or I will run a  little over. Um so the first step in doing this [20:07] is to index your documents into a vector  database. Um and this is exactly what [20:14] we discussed before about we learned about  vectors. So you have a database and you just put [20:21] your vectors right here into your database and  then the sentence that they are representing. [20:28] And you do that for every sentence in  your so you take all your legal memos, [20:34] you chunk them up into sentences or you  chunk them up in an appropriate way. Um, [20:40] sentences are good because a you  want something that can hold one idea [20:45] because a vector holds about one idea and a  sentence more or less holds about one idea. [20:50] So then you generate vector embeddings for all  of them. you put it into your database and then [21:00] you create a whole pipeline. And so now  what this pipeline is going to do is a user [21:06] is going to ask a question the query. We're going  to create a vector embedding of the user's query. [21:13] So now we have this vector embedding and we have  this whole database of vector embeddings. We're [21:18] going to do a similarity search to find which of  these vector embeddings here are closest to the [21:25] vector embedding we made from the user's query.  And this is the exact same type of similarity [21:32] search that I was doing with the duplicate checker  example. And then you take like the top five or 10 [21:37] hits, you find those sentences and they're going  to be sentences within legal memos. So you take [21:43] the some context around them as well. So, you want  to get like the paragraph they're in because you [21:49] don't want to just give the sentence because  the LLM needs a little more context than that. [21:53] And then you take that whole pipeline and you feed  it back into um the LLM with a prompt telling it [22:05] these this is what I've pulled that's relevant  to the user's query. Answer the user's query [22:13] and don't make up stuff. only answer based on  the text given da da and that's it and that is [22:21] what we call retrieval augmented generation.  Um and so yeah exactly with this process [22:30] uh we deployed a model first very slow then we  got better hardware and now runs a lot faster and [22:37] it just opened up the ability to go new places  where now we're building out a whole now we're [22:44] we're focusing more on MCP uh agents and  uh building out like chat bots. This is [22:52] a chatbot essentially. Everything is a  chatbot uh with other capabilities. And [22:57] yeah, hope you enjoy enjoyed the talk and  got something useful out of it. Thank you.