<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Soonmo Seong on Medium]]></title>
        <description><![CDATA[Stories by Soonmo Seong on Medium]]></description>
        <link>https://medium.com/@soonmo.seong?source=rss-f88a078b557a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*qsyzk-MRjyOPc-Qf</url>
            <title>Stories by Soonmo Seong on Medium</title>
            <link>https://medium.com/@soonmo.seong?source=rss-f88a078b557a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 03:45:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@soonmo.seong/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[vLLM을 사용한 Gemma-4 간단 서빙 가이드]]></title>
            <link>https://medium.com/@soonmo.seong/vllm%EC%9D%84-%EC%82%AC%EC%9A%A9%ED%95%9C-gemma-4-%EA%B0%84%EB%8B%A8-%EC%84%9C%EB%B9%99-%EA%B0%80%EC%9D%B4%EB%93%9C-5e1908af6565?source=rss-f88a078b557a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e1908af6565</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[google-gemma]]></category>
            <category><![CDATA[vllm]]></category>
            <dc:creator><![CDATA[Soonmo Seong]]></dc:creator>
            <pubDate>Tue, 07 Apr 2026 06:05:31 GMT</pubDate>
            <atom:updated>2026-04-07T06:07:29.140Z</atom:updated>
            <content:encoded><![CDATA[<p>vLLM은 LLM 추론과 서빙을 위한 빠르고 사용하기 쉬운 라이브러리입니다. 이를 H100환경에서 `python`으로 vLLM을 설치하고 Google의 Gemma-4를 서빙하여 추론하는 방법을 알아보겠습니다.</p><h3>vLLM installation</h3><p>vLLM을 사용하기 위해 먼저 Python 가상 환경을 설정하고 관련 패키지를 설치해야 합니다. 여기서는 빠르고 가벼운 패키지 관리자인 uv를 사용하여 독립적인 환경을 구성해 보겠습니다.</p><pre>uv venv --python 3.12 --seed --managed-python<br>source .venv/bin/activate<br>uv pip install vllm --torch-backend=auto</pre><h3>Gemma-4 Serving</h3><h3>gemma-4–31B-it</h3><pre>vllm serve google/gemma-4-31B-it \<br>--tensor-parallel-size 2 \<br>  --max-model-len 32768 \<br>  --gpu-memory-utilization 0.90</pre><h3>gemma-4-E4B-it</h3><pre>vllm serve google/gemma-4-E4B-it \<br>  --max-model-len &lt;n_of_tokens&gt; # up to 131072</pre><p>Serving하는데 시간이 좀 걸립니다. 모델이 클수록 초기 세팅시 시간이 오래 걸립니다. port 8000으로 통신 가능합니다.</p><h3>Inference</h3><h3>gemma-4–31B-it</h3><pre>from openai import OpenAI<br><br>client = OpenAI(base_url=&quot;http://localhost:8000/v1&quot;, api_key=&quot;EMPTY&quot;)<br>response = client.chat.completions.create(<br>    # model=&quot;google/gemma-4-E4B-it&quot;,<br>    model=&quot;google/gemma-4-31B-it&quot;,<br>    messages=[{&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;Write a poem about King Sejong in Korean.&quot;}],<br>    max_tokens=512,<br>    temperature=0.7,<br>)<br>print(response.choices[0].message.content)</pre><p>위의 스크립트를 uv run main.py로 실행하면 아래와 같은 결과를 보여줍니다. vllm으로 gemma-4-31b가 잘 서빙되는 것을 알 수 있습니다. gemma-4-E4B-it 모델의 경우, <a href="#gemma-4-e4b-it">gemma-4-E4B-it 모델 서빙 후</a> model=&quot;google/gemma-4-E4B-it&quot;으로 변경하여 실행하면 gemma-4-E4B-it의 추론 결과를 얻을 수 있습니다.</p><pre>In the halls of Gyeongbokgung, where the morning mist clings,<br>Sat a scholar, a dreamer, the wisest of kings.<br>Not with the sword did he carve out his name,<br>But with ink and with insight, he kindled a flame.</pre><pre>He looked on his people, their voices unheard,<br>For the script of the empire was a locked, distant word.<br>The Hanja was heavy, a mountain to climb,<br>A barrier built by the passage of time.</pre><pre>&quot;My people,&quot; he whispered, &quot;should not struggle to speak,<br>The truth should be open, the pathway not bleak.<br>Why should a farmer, a weaver, a child,<br>Be kept from the knowledge, their spirits exiled?&quot;</pre><pre>So he labored in silence, through the watch of the night,<br>Turning sounds into symbols, bringing darkness to light.<br>He studied the tongue, the breath, and the bone,<br>Until a new alphabet was carved into stone.</pre><pre>Twenty-eight letters, a gift from the throne,<br>A seed of literacy, carefully sown.<br>*Hunminjeongeum*—the sounds that are right,<br>Giving the voiceless the power of sight.</pre><pre>But his vision reached further than the brush and the page,<br>He ushered his kingdom into a golden age.<br>He measured the rain, he tracked every star,<br>Bringing the secrets of heaven from afar.</pre><pre>The water-clock ticked with a rhythmic precision,<br>The sundial mirrored his scientific vision.<br>From music to medicine, from farming to law,<br>A kingdom of logic, devoid of a flaw.</pre><pre>He loved not the glory, the crown, or the pride,<br>But the hope that his people would flourish and stride.<br>A king who knelt low to lift others on high,<br>Whose legacy echoes beneath the Korean sky.</pre><pre>Oh, Sejong the Great, with the heart of a sage,<br>You wrote for the future a luminous page.<br>Though centuries vanish, your wisdom remains,<br>Breaking the silence, dissolving the chains.</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e1908af6565" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Snowflake Cortex Code (CoCo)Skills Guide (Practical Code Examples)]]></title>
            <link>https://medium.com/@soonmo.seong/snowflake-cortex-code-coco-skills-guide-practical-code-examples-309663122e37?source=rss-f88a078b557a------2</link>
            <guid isPermaLink="false">https://medium.com/p/309663122e37</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[cortex-code]]></category>
            <category><![CDATA[data-superhero]]></category>
            <dc:creator><![CDATA[Soonmo Seong]]></dc:creator>
            <pubDate>Wed, 01 Apr 2026 01:17:13 GMT</pubDate>
            <atom:updated>2026-04-01T01:17:13.637Z</atom:updated>
            <content:encoded><![CDATA[<p>Since the launch of Cortex Code, many data engineers have been actively using it within Snowflake with great satisfaction. We have summarized the <strong>10 Core Skills</strong> essential for maximizing AI capabilities and effectively managing data assets in your Snowflake environment.</p><p>These skills are designed to help you leverage AI features seamlessly. Read on to discover the definition, key features, and primary use cases for each skill, along with practical code snippets (SQL/Python) that you can apply immediately to your work. When you ask a question in natural language, Cortex automatically generates and executes these code snippets. Note that while these skills can be automatically invoked, you can also manually call them as needed</p><h3>🎯 Big Picture for Ambition: 10 Essential Skills for Snowflake Masters</h3><p>To fuel your technical ambition and help you easily grasp the broader ecosystem, we’ve summarized the fundamental purpose of the 10 core skills below. This introductory roadmap will guide you through the essentials — keep these in mind and draw upon the appropriate skill for your specific domain whenever you tackle hands-on challenges.</p><ol><li><strong>cortex-ai-functions</strong> (AI Analytics): Text (classification, summarization, translation, extraction) &amp; Document analysis</li><li><strong>cost-intelligence</strong> (Cost Mgt.): Credit consumption &amp; usage tracking, Budget control &amp; Resource surveying</li><li><strong>data-cleanrooms</strong> (Data Collaboration): Encrypted Clean Room provisioning, cross-audience overlap auditing, and shared B2B data exchanges</li><li><strong>data-governance</strong> (Data Security): Automatic Data classification of sensitive identities (PII), dynamic rule encryptions/maskings &amp; privilege check-ups</li><li><strong>data-quality</strong> (Quality Control): Out-of-the-box Data Quality Metrics (DMF) observing, tracking data syncs &amp; consistency assertions mapping across tables</li><li><strong>dbt-projects-on-snowflake</strong> (dbt Pipelines): Executing, monitoring &amp; scheduling Native SQL administrative behaviors wrapping around nested dbt projects</li><li><strong>integrations</strong> (3rd-Party Integrations): Attaching out-of-bounded Cloud Storages (such as S3) and setting external trigger-based web notifications (e.g. Emails/SNS)</li><li><strong>lineage</strong> (Lineage Tracing): Tracing data lineage pipelines starting originally down to the granular column/table level while projecting structural downstream impact metrics</li><li><strong>machine-learning</strong> (Machine Learning/ML): Handling baseline model tests/trainings, registry deployment bindings and serverless AI algorithmic inferences</li><li><strong>notebooks-in-workspaces</strong> (Workspace Supervision): End-to-end modifications enclosing actual Notebook (.ipynb) records enabling code automation via granular SQL &amp; Python Cells</li></ol><p>The below will provide more details for each skill. You will see practical prompts and code examples for each skill.</p><h3>1. Cortex AI Functions (cortex-ai-functions)</h3><p><strong>Definition</strong>: A skill for text and image analysis using Snowflake Cortex AI functions.</p><p><strong>Key Features</strong>:</p><ul><li>Text classification, sentiment analysis, summarization, translation, and entity extraction.</li><li>Document parsing, PII masking, embedding extraction, filtering, and aggregation.</li></ul><p><strong>When to Use?</strong> Use this when you need to extract meaningful information from text, documents, or images, or when you need to automatically classify, summarize, or translate content.</p><p><strong>Usage Examples</strong> 💬 <em>“Perform sentiment analysis on customer reviews.”</em></p><pre>SELECT<br>    review_text,<br>    SNOWFLAKE.CORTEX.AI_SENTIMENT(review_text) AS sentiment_score<br>FROM my_db.my_schema.customer_reviews<br>ORDER BY sentiment_score DESC;</pre><p>💬 <em>“Extract names and emails from this text.”</em></p><pre>SELECT<br>    SNOWFLAKE.CORTEX.AI_EXTRACT(content, [&#39;name&#39;, &#39;email&#39;]) AS extracted<br>FROM my_db.my_schema.documents;</pre><p>💬 <em>“Summarize the customer feedback.”</em></p><pre>SELECT<br>    SNOWFLAKE.CORTEX.AI_SUMMARIZE(feedback_text) AS summary<br>FROM my_db.my_schema.feedback;</pre><h3>2. Cost Intelligence (cost-intelligence) [REQUIRED]</h3><p><strong>Definition</strong>: A skill for analyzing and optimizing Snowflake costs and billing.</p><p><strong>Key Features</strong>:</p><ul><li>Credit/cost analysis and tracking specific costs for warehouses, serverless features, and storage.</li><li>Budget setup and management, resource monitoring, and cost anomaly detection.</li></ul><p><strong>When to Use?</strong> This skill is <strong>automatically invoked</strong> whenever questions arise regarding costs, credits, billing, budgets, or general expenditures.</p><p><strong>Usage Examples</strong> 💬 <em>“Show me the costs by warehouse for this month.”</em></p><pre>SELECT<br>    warehouse_name,<br>    SUM(credits_used) AS total_credits<br>FROM snowflake.account_usage.warehouse_metering_history<br>WHERE start_time &gt;= DATE_TRUNC(&#39;MONTH&#39;, CURRENT_DATE())<br>GROUP BY warehouse_name<br>ORDER BY total_credits DESC;</pre><p>💬 <em>“What are the top 5 most expensive queries?”</em></p><pre>SELECT<br>    query_id,<br>    user_name,<br>    warehouse_name,<br>    execution_time / 1000 AS execution_seconds,<br>    credits_used_cloud_services<br>FROM snowflake.account_usage.query_history<br>WHERE start_time &gt;= DATEADD(&#39;DAY&#39;, -7, CURRENT_DATE())<br>ORDER BY execution_time DESC<br>LIMIT 5;</pre><h3>3. Data Clean Rooms (data-cleanrooms)</h3><p><strong>Definition</strong>: A skill for managing secure collaborations using Snowflake Data Clean Rooms (DCR).</p><p><strong>Key Features</strong>:</p><ul><li>Clean room creation, collaboration participation, invitations, and reviews.</li><li>Audience overlap analysis, segment activation, and exporting.</li></ul><p><strong>When to Use?</strong> Use this for sharing and collaborating on data with partners while preserving data privacy policies, or when clean-room-based analysis is required.</p><p><strong>Usage Examples</strong> 💬 <em>“List current collaborations.”</em></p><pre>CALL SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.CONSUMER.VIEW_COLLABORATIONS();</pre><p>💬 <em>“Run an audience overlap analysis.”</em></p><pre>CALL SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.CONSUMER.RUN_ANALYSIS(<br>    &#39;my_collaboration&#39;,<br>    &#39;overlap_analysis&#39;,<br>    [&#39;my_db.my_schema.my_table&#39;],<br>    OBJECT_CONSTRUCT(&#39;dimensions&#39;, [&#39;region&#39;, &#39;age_group&#39;])<br>);</pre><h3>4. Data Governance (data-governance) [REQUIRED]</h3><p><strong>Definition</strong>: A comprehensive data governance integration skill that encompasses robust security and control (includes 5 sub-skills).</p><p><strong>Key Features</strong>:</p><ul><li>Dynamic Out-of-the-box Masking and Row Access Policies.</li><li>Automatic PII (Personally Identifiable Information) classification, authorization auditing, and data governance maturity evaluation.</li></ul><p><strong>When to Use?</strong> This skill is called upon when establishing data privacy policies, classifying and masking sensitive data (PII), or auditing user permissions.</p><p><strong>Usage Examples</strong> 💬 <em>“Apply a masking policy to the email column.”</em></p><pre>CREATE OR REPLACE MASKING POLICY my_db.my_schema.email_mask AS<br>(val STRING) RETURNS STRING -&gt;<br>    CASE<br>        WHEN CURRENT_ROLE() IN (&#39;ADMIN&#39;) THEN val<br>        ELSE &#39;***MASKED***&#39;<br>    END;</pre><pre>ALTER TABLE my_db.my_schema.customers<br>    MODIFY COLUMN email<br>    SET MASKING POLICY my_db.my_schema.email_mask;</pre><p>💬 <em>“Scan and classify sensitive data in this table.”</em></p><pre>SELECT * FROM TABLE(<br>    SNOWFLAKE.DATA_PRIVACY.SYSTEM$CLASSIFY(<br>        &#39;my_db.my_schema.customers&#39;,<br>        OBJECT_CONSTRUCT(&#39;auto_tag&#39;, TRUE)<br>    )<br>);</pre><p>💬 <em>“Show the data access history for the last 7 days.”</em></p><pre>SELECT<br>    user_name, <br>    query_start_time,<br>    base_objects_accessed<br>FROM snowflake.account_usage.access_history<br>WHERE query_start_time &gt;= DATEADD(&#39;DAY&#39;, -7, CURRENT_DATE())<br>ORDER BY query_start_time DESC<br>LIMIT 100;</pre><h3>5. Data Quality (data-quality)</h3><p><strong>Definition</strong>: A monitoring skill for continuously verifying data reliability using Data Metric Functions (DMF).</p><p><strong>Key Features</strong>:</p><ul><li>Schema-level quality monitoring and data comparison across tables.</li><li>DMF setup/management, quality SLA notifications, and incident investigation.</li></ul><p><strong>When to Use?</strong> Required to verify data integrity after a load/migration, or when setting up an environment to monitor the quality of data pipelines continuously.</p><p><strong>Usage Examples</strong> 💬 <em>“Set up a Null-check Data Quality Metric (DMF) on the orders table.”</em></p><pre>ALTER TABLE my_db.my_schema.orders<br>    SET DATA_METRIC_SCHEDULE = &#39;TRIGGER_ON_CHANGES&#39;;</pre><pre>ALTER TABLE my_db.my_schema.orders<br>    ADD DATA METRIC FUNCTION<br>    SNOWFLAKE.CORE.NULL_COUNT ON (order_id);</pre><p>💬 <em>“Retrieve the recent DMF measurement results.”</em></p><pre>SELECT *<br>FROM SNOWFLAKE.LOCAL.DATA_QUALITY_MONITORING_RESULTS<br>WHERE TABLE_NAME = &#39;ORDERS&#39;<br>ORDER BY MEASUREMENT_TIME DESC<br>LIMIT 20;</pre><p>💬 <em>“Compare data between Table A and Table B (Data integrity check).”</em></p><pre>SELECT &#39;source_only&#39; AS source, COUNT(*) AS cnt<br>FROM my_db.my_schema.table_a a<br>LEFT JOIN my_db.my_schema.table_b b ON a.id = b.id<br>WHERE b.id IS NULL<br>UNION ALL<br>SELECT &#39;target_only&#39;, COUNT(*)<br>FROM my_db.my_schema.table_b b<br>LEFT JOIN my_db.my_schema.table_a a ON b.id = a.id<br>WHERE a.id IS NULL;</pre><h3>6. dbt Projects on Snowflake (dbt-projects-on-snowflake)</h3><p><strong>Definition</strong>: A skill for managing and executing natively deployed dbt projects within Snowflake via SQL commands.</p><p><strong>Key Features</strong>:</p><ul><li>Supports ALTER / EXECUTE / DROP / DESCRIBE / SHOW DBT PROJECT commands.</li><li>Scheduling, documentation, and execution monitoring for dbt projects.</li></ul><p><strong>When to Use?</strong> Commonly used when you want to natively execute and operate deployed dbt core pipelines directly through SQL from within Snowsight.</p><p><strong>Usage Examples</strong> 💬 <em>“Run a specific model from the deployed dbt project.”</em></p><pre>EXECUTE DBT PROJECT my_db.my_schema.my_dbt_project<br>    ARGS = &#39;run --select my_model&#39;;</pre><p>💬 <em>“Show a list of all registered dbt projects.”</em></p><pre>SHOW DBT PROJECTS IN SCHEMA my_db.my_schema;</pre><p>💬 <em>“Schedule the dbt project to run every morning at 6 AM.”</em></p><pre>CREATE OR REPLACE TASK my_db.my_schema.daily_dbt_run<br>    WAREHOUSE = my_wh<br>    SCHEDULE = &#39;USING CRON 0 6 * * * America/Los_Angeles&#39;<br>AS<br>    EXECUTE DBT PROJECT my_db.my_schema.my_dbt_project<br>    ARGS = &#39;run&#39;;</pre><h3>7. Integrations (integrations)</h3><p><strong>Definition</strong>: A skill used for configuring Integration objects to connect Snowflake with external systems.</p><p><strong>Key Features</strong>:</p><ul><li>Setting up and managing connections to external APIs, cloud storage (AWS S3, Google GCS, Azure Blob), and notification services (Emails, SNS, etc.).</li></ul><p><strong>When to Use?</strong> Utilize this when data needs to be exchanged with outer systems outside of the Data Warehouse environment, or when an event notification has to be fired off.</p><p><strong>Usage Examples</strong> 💬 <em>“Create an Amazon S3 storage integration pipeline.”</em></p><pre>CREATE OR REPLACE STORAGE INTEGRATION s3_integration<br>    TYPE = EXTERNAL_STAGE<br>    STORAGE_PROVIDER = &#39;S3&#39;<br>    ENABLED = TRUE<br>    STORAGE_AWS_ROLE_ARN = &#39;arn:aws:iam::123456789:role/myrole&#39;<br>    STORAGE_ALLOWED_LOCATIONS = (&#39;s3://my-bucket/path/&#39;);</pre><p>💬 <em>“Set up an email notification integration.”</em></p><pre>CREATE OR REPLACE NOTIFICATION INTEGRATION my_email_int<br>    TYPE = EMAIL<br>    ENABLED = TRUE<br>    ALLOWED_RECIPIENTS = (&#39;user@example.com&#39;);</pre><h3>8. Data Lineage (lineage)</h3><p><strong>Definition</strong>: A skill dedicated to visualizing and exploring data lineage and mapping dependencies among Snowflake objects.</p><p><strong>Key Features</strong>:</p><ul><li>Change impact analysis, root-cause debugging, and column-level trace visibility.</li></ul><p><strong>When to Use?</strong> Use this whenever a table or view is modified to understand its repercussions on downstream workflows, or to trace back the exact origin of specific populated data.</p><p><strong>Usage Examples</strong> 💬 <em>“Show me the downstream dependencies for this specific table.”</em></p><pre>SELECT<br>    referencing_object_name,<br>    referencing_object_domain,<br>    referenced_object_name,<br>    referenced_object_domain<br>FROM snowflake.account_usage.object_dependencies<br>WHERE referenced_object_name = &#39;MY_TABLE&#39;<br>    AND referenced_database_name = &#39;MY_DB&#39;;</pre><p>💬 <em>“Trace where the data residing in this column originally got loaded from.”</em></p><pre>SELECT<br>    directSources.value:&quot;objectName&quot;::STRING AS source_object,<br>    directSources.value:&quot;columnName&quot;::STRING AS source_column,<br>    columns.value:&quot;columnName&quot;::STRING AS target_column<br>FROM snowflake.account_usage.access_history,<br>    LATERAL FLATTEN(input =&gt; objects_modified) AS om,<br>    LATERAL FLATTEN(input =&gt; om.value:&quot;columns&quot;) AS columns,<br>    LATERAL FLATTEN(input =&gt; columns.value:&quot;directSources&quot;) AS directSources<br>WHERE query_start_time &gt;= DATEADD(&#39;DAY&#39;, -1, CURRENT_DATE())<br>LIMIT 50;</pre><h3>9. Machine Learning (machine-learning) [REQUIRED]</h3><p><strong>Definition</strong>: A complete skill meant to natively support End-to-End machine learning workflows directly inside of Snowflake, straight from data preparation up to model deployment.</p><p><strong>Key Features</strong>:</p><ul><li>Model training, saving/deploying via ML Registry(Model Registry), and Serverless-based inferencing.</li><li>Managing Feature Stores, logging experimental trials, and tweaking hyperparameters.</li></ul><p><strong>When to Use?</strong> This is <strong>strictly auto-invoked</strong> effectively providing compatibility and execution contexts whenever machine-learning workloads or data science requirements are explicitly mentioned.</p><p><strong>Usage Examples</strong> 💬 <em>“Train an XGBoost model and register it the the ML Registry. (Python Notebook Env.)”</em></p><pre>from snowflake.ml.registry import Registry<br>from snowflake.ml.modeling.xgboost import XGBClassifier</pre><pre># 1. Train the model<br>model = XGBClassifier(<br>    input_cols=[&quot;FEATURE_1&quot;, &quot;FEATURE_2&quot;],<br>    label_cols=[&quot;TARGET&quot;],<br>    output_cols=[&quot;PREDICTION&quot;]<br>)<br>model.fit(train_df)</pre><pre># 2. Register the model into the Registry<br>registry = Registry(session=session)<br>mv = registry.log_model(<br>    model=model,<br>    model_name=&quot;my_xgb_model&quot;,<br>    version_name=&quot;v1&quot;,<br>    sample_input_data=train_df.limit(10),<br>    metrics={&quot;accuracy&quot;: 0.95}<br>)</pre><p>💬 <em>“Load up a registered model’s architecture and execute inferencing against new arriving sets of data. (SQL Env.)”</em></p><pre>SELECT *,<br>    my_db.my_schema.my_xgb_model!PREDICT(feature_1, feature_2) AS prediction<br>FROM my_db.my_schema.new_data;</pre><h3>10. Notebooks in Workspaces (notebooks-in-workspaces) [REQUIRED for notebooks]</h3><p><strong>Definition</strong>: A crucial, core skill to control standard .ipynb notebook behavior within Snowflake Workspaces.</p><p><strong>Key Features</strong>:</p><ul><li>Fully automates file creation, reading, modification, and execution of Notebooks.</li><li>Overall kernel tracking and administration, Cell addition/deletion alongside pipeline migration handling.</li></ul><p><strong>When to Use?</strong> Normally acts as <strong>the primal priority called</strong> surrounding any Python/Notebook file queries issued inside the Workspace ecosystem.</p><p><strong>Usage Examples</strong> 💬 <em>“Structure out a notebook cell blueprint executing some Exploratory Data Analysis (EDA).”</em></p><p><strong>Cell 1 (SQL)</strong> - Data Query</p><pre>SELECT * FROM my_db.my_schema.sales_data LIMIT 1000;</pre><p><strong>Cell 2 (Python)</strong> - Pandas casting &amp; profiling</p><pre>import pandas as pd<br>import matplotlib.pyplot as plt</pre><pre># Pull over the previously fetched SQL results into a Python DataFrame<br>df = cell1.to_pandas()<br>print(f&quot;Shape: {df.shape}&quot;)<br>df.describe()</pre><p><strong>Cell 3 (Python)</strong> - Further Data Visualizations</p><pre># Visualize revenue breakdowns across respective categories.<br>df.groupby(&#39;category&#39;)[&#39;revenue&#39;].sum().plot(kind=&#39;bar&#39;)<br>plt.title(&#39;Revenue by Category&#39;)<br>plt.ylabel(&#39;Revenue&#39;)<br>plt.tight_layout()<br>plt.show()</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=309663122e37" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Snowflake Cortex Code(CoCo) Skills 핵심 가이드]]></title>
            <link>https://medium.com/@soonmo.seong/snowflake-cortex-code-coco-skills-%ED%95%B5%EC%8B%AC-%EA%B0%80%EC%9D%B4%EB%93%9C-6929fd23784f?source=rss-f88a078b557a------2</link>
            <guid isPermaLink="false">https://medium.com/p/6929fd23784f</guid>
            <category><![CDATA[skills]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[snowflake-cortex]]></category>
            <category><![CDATA[cortex-code]]></category>
            <dc:creator><![CDATA[Soonmo Seong]]></dc:creator>
            <pubDate>Tue, 31 Mar 2026 06:32:50 GMT</pubDate>
            <atom:updated>2026-03-31T06:40:01.368Z</atom:updated>
            <content:encoded><![CDATA[<p>Cortex Code가 출시된 이후 많은 데이터 엔지니어들이 만족하며 스노우플레이크 안에서 사용하고 있습니다. Snowflake 환경에서 AI 기능을 극대화하고, 데이터 자산을 효율적으로 관리하기 위한 <strong>핵심 10가지 스킬</strong>을 정리했습니다. 이 스킬들이 인공지능의 기능을 더 잘 활용할 수 있도록 도와주고 있습니다. 각 스킬의 정의, 주요 기능, 활용 시점을 알아보고, 실무에 즉시 적용할 수 있는 코드 스니펫(SQL/Python)도 함께 확인해 보세요. 자연어로 질의하면 아래와 코드 스니펫을 자동행성하고 실행합니다. 참고로 이 스킬들은 자동으로 호출되어 사용되고 사용자가 직접 호출해서 사용할 수도 있습니다.</p><h3>🎯 Snowflake CoCo Skills</h3><p>전체 흐름을 한눈에 파악할 수 있도록 10가지 스킬의 핵심은 다음과 같습니다. 실무 작업 시 필요한 영역에 맞추어 적절한 스킬을 활용해 보세요.</p><ol><li><strong>cortex-ai-functions</strong> (AI 분석): 텍스트(분류, 요약, 번역, 정보 추출) 및 문서 분석</li><li><strong>cost-intelligence</strong> (비용 관리): 크레딧 소모량/비용 추적, 예산 관리 및 리소스 모니터링</li><li><strong>data-cleanrooms</strong> (데이터 협업): 보안 클린룸 생성, 오디언스 오버랩 분석 및 파트너 간 데이터 공유</li><li><strong>data-governance</strong> (데이터 보안): 민감 데이터(PII) 자동 스캔 및 분류, 동적 마스킹, 권한 감사</li><li><strong>data-quality</strong> (품질 관리): 데이터 품질 메트릭(DMF) 모니터링, 테이블 간 동기화 정합성 검증</li><li><strong>dbt-projects-on-snowflake</strong> (dbt 파이프라인): dbt 프로젝트의 네이티브 SQL 관리(실행, 스케줄링, 모니터링)</li><li><strong>integrations</strong> (외부 통합): 외부 클라우드 스토리지(S3 등) 연동 연결 및 알림(Email 등) 설정</li><li><strong>lineage</strong> (리니지 분석): 컬럼 단위 데이터 파생 출처 추적 및 변경 시 다운스트림 영향도 파악</li><li><strong>machine-learning</strong> (머신러닝(ML)): 모델 학습, ML 레지스트리 모델 배포 및 인프라리스 서버에서 추론</li><li><strong>notebooks-in-workspaces</strong> (Workspace 제어): 노트북(.ipynb) 파일 편집 관리 및 SQL/Python 셀 기반 실행 자동화</li></ol><p>주요 기능과 자세한 사용 예시는 아래에서 이어집니다.</p><h3>1. Cortex AI Functions (cortex-ai-functions)</h3><p><strong>정의</strong>: Snowflake Cortex AI 함수를 활용한 텍스트/이미지 분석 스킬입니다.</p><p><strong>주요 기능</strong>:</p><ul><li>텍스트 분류, 감정 분석, 요약, 번역, 엔티티 추출</li><li>문서 파싱, PII 마스킹, 임베딩, 필터링, 집계</li></ul><p><strong>언제 사용하나요?</strong> 텍스트, 문서, 이미지에서 유의미한 정보를 추출하거나 콘텐츠를 자동 분류·요약·번역해야 할 때 활용합니다.</p><p><strong>활용 예시</strong></p><p>💬 <em>“고객 리뷰의 감정 분석을 해줘”</em></p><pre>SELECT<br>    review_text,<br>    SNOWFLAKE.CORTEX.AI_SENTIMENT(review_text) AS sentiment_score<br>FROM my_db.my_schema.customer_reviews<br>ORDER BY sentiment_score DESC;</pre><p>💬 <em>“이 텍스트에서 이름과 이메일을 추출해줘”</em></p><pre>SELECT<br>    SNOWFLAKE.CORTEX.AI_EXTRACT(content, [&#39;name&#39;, &#39;email&#39;]) AS extracted<br>FROM my_db.my_schema.documents;</pre><p>💬 <em>“고객 피드백을 요약해줘”</em></p><pre>SELECT<br>    SNOWFLAKE.CORTEX.AI_SUMMARIZE(feedback_text) AS summary<br>FROM my_db.my_schema.feedback;</pre><h3>2. Cost Intelligence (cost-intelligence) [REQUIRED]</h3><p><strong>정의</strong>: Snowflake 비용 및 청구 관련 최적화·분석 스킬입니다.</p><p><strong>주요 기능</strong>:</p><ul><li>크레딧/비용 분석 및 웨어하우스·서버리스·스토리지 비용 추적</li><li>예산 설정 및 관리, 리소스 모니터링, 비용 이상치 탐지</li></ul><p><strong>언제 사용하나요?</strong> 비용, 크레딧, 청구, 예산, 지출 등과 관련된 질문 발생 시 <strong>자동 호출</strong>됩니다.</p><p><strong>활용 예시</strong></p><p>💬 <em>“이번 달 웨어하우스별 비용을 보여줘”</em></p><pre>SELECT<br>    warehouse_name,<br>    SUM(credits_used) AS total_credits<br>FROM snowflake.account_usage.warehouse_metering_history<br>WHERE start_time &gt;= DATE_TRUNC(&#39;MONTH&#39;, CURRENT_DATE())<br>GROUP BY warehouse_name<br>ORDER BY total_credits DESC;</pre><p>💬 <em>“가장 비용이 많이 발생한 쿼리 Top 5를 알려줘”</em></p><pre>SELECT<br>    query_id,<br>    user_name,<br>    warehouse_name,<br>    execution_time / 1000 AS execution_seconds,<br>    credits_used_cloud_services<br>FROM snowflake.account_usage.query_history<br>WHERE start_time &gt;= DATEADD(&#39;DAY&#39;, -7, CURRENT_DATE())<br>ORDER BY execution_time DESC<br>LIMIT 5;</pre><h3>3. Data Clean Rooms (data-cleanrooms)</h3><p><strong>정의</strong>: Snowflake Data Clean Room(DCR)을 활용한 안전한 협업 관리 스킬입니다.</p><p><strong>주요 기능</strong>:</p><ul><li>클린룸 생성, 협업 참여/초대/검토 기능</li><li>오디언스 오버랩 분석(Audience Overlap), 세그먼트 활성화 및 내보내기</li></ul><p><strong>언제 사용하나요?</strong> 데이터 보안 정책을 유지하면서 파트너사와 데이터를 공유·협업하거나 클린룸 기반의 분석이 필요할 때 사용합니다.</p><p><strong>활용 예시</strong></p><p>💬 <em>“현재 협업 목록을 조회해줘”</em></p><pre>CALL SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.CONSUMER.VIEW_COLLABORATIONS();</pre><p>💬 <em>“오디언스 오버랩 분석을 실행해줘”</em></p><pre>CALL SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.CONSUMER.RUN_ANALYSIS(<br>    &#39;my_collaboration&#39;,<br>    &#39;overlap_analysis&#39;,<br>    [&#39;my_db.my_schema.my_table&#39;],<br>    OBJECT_CONSTRUCT(&#39;dimensions&#39;, [&#39;region&#39;, &#39;age_group&#39;])<br>);</pre><h3>4. Data Governance (data-governance) [REQUIRED]</h3><p><strong>정의</strong>: 강력한 보안과 통제를 위한 Snowflake 데이터 거버넌스 통합 메뉴(5개 하위 스킬 포함)입니다.</p><p><strong>주요 기능</strong>:</p><ul><li>동적 마스킹(Masking) 및 행 접근 정책(Row Access Policy)</li><li>개인정보(PII) 자동 분류, 권한 감사, 데이터 거버넌스 성숙도 평가</li></ul><p><strong>언제 사용하나요?</strong> 데이터 보안 정책 수립, 민감 데이터(PII) 분류 및 마스킹, 사용자 권한 감사가 필요할 때 호출됩니다.</p><p><strong>활용 예시</strong></p><p>💬 <em>“이메일 컬럼에 마스킹 정책을 적용해줘”</em></p><pre>CREATE OR REPLACE MASKING POLICY my_db.my_schema.email_mask AS<br>(val STRING) RETURNS STRING -&gt;<br>    CASE<br>        WHEN CURRENT_ROLE() IN (&#39;ADMIN&#39;) THEN val<br>        ELSE &#39;***MASKED***&#39;<br>    END;</pre><pre>ALTER TABLE my_db.my_schema.customers<br>    MODIFY COLUMN email<br>    SET MASKING POLICY my_db.my_schema.email_mask;</pre><p>💬 <em>“이 테이블에서 민감 데이터를 스캔하고 분류해줘”</em></p><pre>SELECT * FROM TABLE(<br>    SNOWFLAKE.DATA_PRIVACY.SYSTEM$CLASSIFY(<br>        &#39;my_db.my_schema.customers&#39;,<br>        OBJECT_CONSTRUCT(&#39;auto_tag&#39;, TRUE)<br>    )<br>);</pre><p>💬 <em>“최근 7일간의 데이터 접근 이력을 조회해줘”</em></p><pre>SELECT<br>    user_name, <br>    query_start_time,<br>    base_objects_accessed<br>FROM snowflake.account_usage.access_history<br>WHERE query_start_time &gt;= DATEADD(&#39;DAY&#39;, -7, CURRENT_DATE())<br>ORDER BY query_start_time DESC<br>LIMIT 100;</pre><h3>5. Data Quality (data-quality)</h3><p><strong>정의</strong>: Data Metric Functions(DMF)를 활용하여 지속적으로 데이터 신뢰성을 검증하는 모니터링 스킬입니다.</p><p><strong>주요 기능</strong>:</p><ul><li>스키마 수준 품질 모니터링 및 테이블 간 데이터 비교</li><li>DMF 설정/관리, 품질 SLA 알림 및 인시던트(Incident) 조사</li></ul><p><strong>언제 사용하나요?</strong> 데이터 적재/마이그레이션 후 무결성을 검증하거나, 데이터 파이프라인 품질 모니터링 환경을 설정할 때 필요합니다.</p><p><strong>활용 예시</strong></p><p>💬 <em>“주문 테이블에 Null 체크 데이터 품질 메트릭(DMF)을 설정해줘”</em></p><pre>ALTER TABLE my_db.my_schema.orders<br>    SET DATA_METRIC_SCHEDULE = &#39;TRIGGER_ON_CHANGES&#39;;<br>ALTER TABLE my_db.my_schema.orders<br>    ADD DATA METRIC FUNCTION<br>    SNOWFLAKE.CORE.NULL_COUNT ON (order_id);</pre><p>💬 <em>“최근의 DMF 측정 결과를 조회해줘”</em></p><pre>SELECT *<br>FROM SNOWFLAKE.LOCAL.DATA_QUALITY_MONITORING_RESULTS<br>WHERE TABLE_NAME = &#39;ORDERS&#39;<br>ORDER BY MEASUREMENT_TIME DESC<br>LIMIT 20;</pre><p>💬 <em>“A 테이블과 B 테이블의 데이터를 비교해줘 (데이터 정합성 체크)”</em></p><pre>SELECT &#39;source_only&#39; AS source, COUNT(*) AS cnt<br>FROM my_db.my_schema.table_a a<br>LEFT JOIN my_db.my_schema.table_b b ON a.id = b.id<br>WHERE b.id IS NULL<br>UNION ALL<br>SELECT &#39;target_only&#39;, COUNT(*)<br>FROM my_db.my_schema.table_b b<br>LEFT JOIN my_db.my_schema.table_a a ON b.id = a.id<br>WHERE a.id IS NULL;</pre><h3>6. dbt Projects on Snowflake (dbt-projects-on-snowflake)</h3><p><strong>정의</strong>: Snowflake 내부에 배포된 dbt 프로젝트를 SQL 명령어로 실행하고 관리하는 스킬입니다.</p><p><strong>주요 기능</strong>:</p><ul><li>ALTER / EXECUTE / DROP / DESCRIBE / SHOW DBT PROJECT 명령어 지원</li><li>dbt 프로젝트 스케줄링, 문서화, 실행 모니터링</li></ul><p><strong>언제 사용하나요?</strong> Snowsight에 통합 배포된 dbt 코어 파이프라인을 SQL 환경에서 네이티브하게 실행·운영하고자 할 때 주로 씁니다.</p><p><strong>활용 예시</strong></p><p>💬 <em>“배포된 dbt 프로젝트의 특정 모델을 실행해줘”</em></p><pre>EXECUTE DBT PROJECT my_db.my_schema.my_dbt_project<br>    ARGS = &#39;run --select my_model&#39;;</pre><p>💬 <em>“등록된 dbt 프로젝트들의 목록을 보여줘”</em></p><pre>SHOW DBT PROJECTS IN SCHEMA my_db.my_schema;</pre><p>💬 <em>“매일 아침 6시에 dbt 프로젝트가 실행되도록 스케줄링해줘”</em></p><pre>CREATE OR REPLACE TASK my_db.my_schema.daily_dbt_run<br>    WAREHOUSE = my_wh<br>    SCHEDULE = &#39;USING CRON 0 6 * * * America/Los_Angeles&#39;<br>AS<br>    EXECUTE DBT PROJECT my_db.my_schema.my_dbt_project<br>    ARGS = &#39;run&#39;;</pre><h3>7. Integrations (integrations)</h3><p><strong>정의</strong>: Snowflake와 외부 시스템을 연결하는 통합(Integration) 객체 설정 스킬입니다.</p><p><strong>주요 기능</strong>:</p><ul><li>외부 API, 클라우드 스토리지(S3, GCS, Blob), 알림(Email, SNS) 등 외부 서비스 연동 객체 생성/관리</li></ul><p><strong>언제 사용하나요?</strong> 데이터 웨어하우스 바깥의 외부 시스템과 데이터를 주고받거나, 이벤트 알림을 발송해야 할 때 사용합니다.</p><p><strong>활용 예시</strong></p><p>💬 <em>“Amazon S3 스토리지 통합 파이프라인을 만들어줘”</em></p><pre>CREATE OR REPLACE STORAGE INTEGRATION s3_integration<br>    TYPE = EXTERNAL_STAGE<br>    STORAGE_PROVIDER = &#39;S3&#39;<br>    ENABLED = TRUE<br>    STORAGE_AWS_ROLE_ARN = &#39;arn:aws:iam::123456789:role/myrole&#39;<br>    STORAGE_ALLOWED_LOCATIONS = (&#39;s3://my-bucket/path/&#39;);</pre><p>💬 <em>“이메일 알림 통합 설정을 만들어줘”</em></p><pre>CREATE OR REPLACE NOTIFICATION INTEGRATION my_email_int<br>    TYPE = EMAIL<br>    ENABLED = TRUE<br>    ALLOWED_RECIPIENTS = (&#39;user@example.com&#39;);</pre><h3>8. Data Lineage (lineage)</h3><p><strong>정의</strong>: 오브젝트 간 데이터 리니지(계보) 및 의존성을 시각화·탐색하는 스킬입니다.</p><p><strong>주요 기능</strong>:</p><ul><li>변경 영향도 분석(Impact Analysis), 원인 추적(Root Cause Debugging), 컬럼 수준 리니지 확보</li></ul><p><strong>언제 사용하나요?</strong> 테이블이나 뷰가 수정될 때 다운스트림 워크플로우에 미치는 영향을 파악하거나, 특정 데이터 파생 출처를 알고 싶을 때 사용합니다.</p><p><strong>활용 예시</strong></p><p>💬 <em>“이 특정 테이블의 다운스트림 의존성을 보여줘”</em></p><pre>SELECT<br>    referencing_object_name,<br>    referencing_object_domain,<br>    referenced_object_name,<br>    referenced_object_domain<br>FROM snowflake.account_usage.object_dependencies<br>WHERE referenced_object_name = &#39;MY_TABLE&#39;<br>    AND referenced_database_name = &#39;MY_DB&#39;;</pre><p>💬 <em>“이 컬럼의 데이터가 최초 어디서 적재되었는지 추적해줘”</em></p><pre>SELECT<br>    directSources.value:&quot;objectName&quot;::STRING AS source_object,<br>    directSources.value:&quot;columnName&quot;::STRING AS source_column,<br>    columns.value:&quot;columnName&quot;::STRING AS target_column<br>FROM snowflake.account_usage.access_history,<br>    LATERAL FLATTEN(input =&gt; objects_modified) AS om,<br>    LATERAL FLATTEN(input =&gt; om.value:&quot;columns&quot;) AS columns,<br>    LATERAL FLATTEN(input =&gt; columns.value:&quot;directSources&quot;) AS directSources<br>WHERE query_start_time &gt;= DATEADD(&#39;DAY&#39;, -1, CURRENT_DATE())<br>LIMIT 50;</pre><h3>9. Machine Learning</h3><p><strong>정의</strong>: 데이터 전처리부터 모델 배포까지, ML 워크플로우 전체를 Snowflake 내부에서 지원하는 스킬입니다.</p><p><strong>주요 기능</strong>:</p><ul><li>모델 학습(Training), ML 레지스트리(Model Registry) 등록 및 배포, 인프라리스(Serverless) 추론</li><li>Feature Store 관리, 실험 추적, 하이퍼파라미터 튜닝</li></ul><p><strong>언제 사용하나요?</strong> 데이터 과학 및 머신러닝 관련 워크로드가 언급될 때 <strong>반드시 호출</strong>되어 실행 환경과 호환되게 작동합니다.</p><p><strong>활용 예시</strong></p><p>💬 <em>“XGBoost 모델을 학습하고 ML 레지스트리에 등록해줘 (Python Notebook 환경)”</em></p><pre>from snowflake.ml.registry import Registry<br>from snowflake.ml.modeling.xgboost import XGBClassifier<br><br># 1. 모델 학습<br>model = XGBClassifier(<br>    input_cols=[&quot;FEATURE_1&quot;, &quot;FEATURE_2&quot;],<br>    label_cols=[&quot;TARGET&quot;],<br>    output_cols=[&quot;PREDICTION&quot;]<br>)<br>model.fit(train_df)<br># 2. 레지스트리에 모델 등록<br>registry = Registry(session=session)<br>mv = registry.log_model(<br>    model=model,<br>    model_name=&quot;my_xgb_model&quot;,<br>    version_name=&quot;v1&quot;,<br>    sample_input_data=train_df.limit(10),<br>    metrics={&quot;accuracy&quot;: 0.95}<br>)</pre><p>💬 <em>“등록된 모델 아키텍처를 불러와서 새로운 데이터에 대해 추론을 실행해줘 (SQL 환경)”</em></p><pre>SELECT *,<br>    my_db.my_schema.my_xgb_model!PREDICT(feature_1, feature_2) AS prediction<br>FROM my_db.my_schema.new_data;</pre><h3>10. Notebooks in Workspaces</h3><p><strong>정의</strong>: Snowflake Workspace 내에서 .ipynb 노트북 환경을 제어하기 위한 필수 스킬입니다.</p><p><strong>주요 기능</strong>:</p><ul><li>노트북 파일 생성/읽기/편집 및 실행 자동화</li><li>커널(Kernel) 관리, 셀 추가/삭제, 파이프라인 마이그레이션</li></ul><p><strong>언제 사용하나요?</strong> Workspace 상에서 파이썬(Python)/노트북 파일 관련된 작업을 요청할 때 <strong>가장 먼저 호출</strong>되는 코어 환경 스킬입니다.</p><p><strong>활용 예시</strong></p><p>💬 <em>“탐색적 데이터 분석(EDA)을 수행하는 노트북 셀 레이아웃을 만들어줘”</em></p><p><strong>셀 1 (SQL)</strong> - 데이터 쿼리</p><pre>SELECT * FROM my_db.my_schema.sales_data LIMIT 1000;</pre><p><strong>셀 2 (Python)</strong> - Pandas 변환 및 요약</p><pre>import pandas as pd<br>import matplotlib.pyplot as plt<br><br># SQL 셀 결과를 Python DataFrame으로 가져오기<br>df = cell1.to_pandas()<br>print(f&quot;Shape: {df.shape}&quot;)<br>df.describe()</pre><p><strong>셀 3 (Python)</strong> - 데이터 시각화</p><pre># 카테고리별 매출 시각화<br>df.groupby(&#39;category&#39;)[&#39;revenue&#39;].sum().plot(kind=&#39;bar&#39;)<br>plt.title(&#39;Revenue by Category&#39;)<br>plt.ylabel(&#39;Revenue&#39;)<br>plt.tight_layout()<br>plt.show()</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6929fd23784f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Snowflake와 AWS CodeCommit 연동하기]]></title>
            <link>https://medium.com/@soonmo.seong/snowflake%EC%99%80-aws-codecommit-%EC%97%B0%EB%8F%99%ED%95%98%EA%B8%B0-8fca19b54705?source=rss-f88a078b557a------2</link>
            <guid isPermaLink="false">https://medium.com/p/8fca19b54705</guid>
            <category><![CDATA[codecommit]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[snowflake]]></category>
            <dc:creator><![CDATA[Soonmo Seong]]></dc:creator>
            <pubDate>Fri, 13 Dec 2024 02:14:23 GMT</pubDate>
            <atom:updated>2024-12-13T02:14:23.241Z</atom:updated>
            <content:encoded><![CDATA[<p>AWS CodeCommit과 연동하는 가이드를 인터넷에서 찾이 어려워 문서를 작성하게 되었습니다. AWS 환경에서 작업을 마친 후 Snowflake로 넘어가서 연동을 마무리하도록 하겠습니다. Workflow는 아래와 같습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*FyKoocZo0kJE7hcUpIZJBA.png" /></figure><h3>1. AWS 환경 설정</h3><h3>1.1 AWS IAM User 생성</h3><p>IAM에서 Users를 클릭합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E20uMeD99hUeqAsKV72I0w.png" /></figure><p>snowflake_codecommit_user라는 유저를 생성합니다. Attach policies directly를 선택하고 AWSCodeCommitPowerUser policy를 붙입니다. 다음으로 넘어가서 유저 생성을 완료합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9bEZsfHuS5_F0FT9lkTY_A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L_0egEERA3lR_oe53ylAUw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9NIXoo4r5smcEro-mGonHw.png" /></figure><p>아래와 같이 생성된 유저가 보입니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F0si_iPefwzt5fRFif0ELw.png" /></figure><p>해당 유저를 클릭하고 들어가서 Security credentials를 선택합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XfggX2mtRHPmGNF85q3MjA.png" /></figure><p>CodeCommit의 아이디와 비밀번호를 생성합니다. 팝업이 뜨면 credentials를 저장합니다. 추후 스노우플레이크에서 접속정보로 활용됩니다. 이렇게 IAM Users에서의 작업은 마치고 CodeCommit으로 넘어가 보겠습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qq2JZTmp_5XZF3-KT0DoWQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*Vn_bkkmII6lZcZSY-qnS7A.png" /></figure><h3>1.2 AWS CodeCommit Repository 생성</h3><p>검색을 통해 CodeCommit으로 이동합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qsY2es5PUm1otmXcL7zWIQ.png" /></figure><p>create repository를 눌러서 새로운 repository를 생성합니다. 이름은 snowflake_repo로 설정하고 생성을 완료합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*stU4P5yPrLZe_xwNjq0b5A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*1G97mKI5saKK5AhxihYjEg.png" /></figure><p>완료 후 HTTPS URL을 복제합니다. 이 URL은 Snowflake에서 GIt Repositories를 생성하는데 사용됩니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bQ9yqYR2NjlSJHwo1PpbQw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JsDf9astvVzXPxIM3xtgGQ.png" /></figure><p>아래와 같은 URL이 클립보드에 복사됩니다.</p><pre>https://git-codecommit.ap-northeast-2.amazonaws.com/v1/repos/snowflake_repo</pre><p>리포지토리에 아래의 간단한 코드가 담긴 파일을 생성해보겠습니다.</p><pre>select<br>    *<br>from<br>    snowflake.account_usage.query_history<br>limit 100<br>    ;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xKVU5mT46_6r52LF9h9n4w.png" /></figure><p>파일이름( sample_code.sql ), Author name, Email address를 설정하고 commit changes를 누릅니다. 이로써 AWS에서 모든 설정이 완료되었습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U-MUcLrgvTvz-vUPWQhFOw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5BL_oCY74sqHIerCiKqeRA.png" /></figure><h3>2. Snowflake Git 연동</h3><h3>2.1 DB &amp; Schema 생성</h3><p>아래와 같은 코드로 DB 및 Schema를 생성합니다. 원활한 생성 및 연동을 위해 accountadmin role을 사용합니다.</p><pre>use role accountadmin;<br><br>create or replace database git_test_db;<br>create or replace schema git_test_schema;<br><br>use database git_test_db;<br>use schema git_test_schema;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lehJVBlpruhU_vsAMDszqg.png" /></figure><h3>2.2 Secret 오브젝트 생성</h3><p>위에서 다운로드 받았던 아이디와 비밀번호를 활용해서 Snowflake Secret 오브젝트( aws_code_commit_secret )를 생성합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hTaFT5V8R60TaYXo3VR5yg.png" /></figure><h3>2.3 API Integration 생성</h3><p>API Integration을 활용하면 AWS와 같은 다른 서비스와 연동하기 쉽습니다. 그래서 AWS CodeCommit과 쉬운 연동을 위해서 API Integration( aws_code_commit_api_integration )를 생성하겠습니다. 위에서 생성한 Secret 오브젝트를 ALLOWED_AUTHENTICATION_SECRETS에 Input 값으로 넣습니다. 그리고 API_ALLOWED_PREFIXES는 AWS CodeCommit에서 생성한 리포지토리의 HTTPS URL을 활용합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o8AEzYAp5ytRfVLbtvti6A.png" /></figure><h3>2.4 GIT REPOSITORY 생성</h3><p>이제 거의 모든 준비가 완료되어서 리포지토리를 생성할 수 있습니다. Origin은 API Integration의 API_ALLOWED_PREFIXES와 같은 값을 넣습니다. 다른 값들은 이미 생성한 Secret 및 API Integration을 활용합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CqpoMDrCobQ89z8Cfz9k6w.png" /></figure><p>GIT_TEST_DB에 생성된 Git Repository를 확인할 수 있습니다. 그리고 샘플 코드가 보입니다. 혹시 보이지 않는다면 아래의 코드를 실행해주세요.</p><pre>ALTER GIT REPOSITORY GIT_TEST_DB.GIT_TEST_SCHEMA.CODE_REPO FETCH;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OR5KMgxd05NwV4R6ksd8Pw.png" /></figure><h3>2.5 Sample Code 실행</h3><p>이제 모든 연동에 필요한 조치들은 완료되었습니다. 그렇다면 코드가 잘 실행되는지 아래의 코드를 실행해 보겠습니다.</p><pre>EXECUTE IMMEDIATE FROM @&quot;GIT_TEST_DB&quot;.&quot;GIT_TEST_SCHEMA&quot;.&quot;CODE_REPO&quot;/branches/main/sample_code.sql;</pre><p>코드가 잘 실행되는 것을 확인할 수 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0PxpIYcCLt1lqxaLkfHLhQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8fca19b54705" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Snowflake Connector(Python)용 AWS Lambda Custom Layer]]></title>
            <link>https://medium.com/cloudvillains/snowflake-connector-python-%EC%9A%A9-aws-lambda-custom-layer-08d57b2ff6e6?source=rss-f88a078b557a------2</link>
            <guid isPermaLink="false">https://medium.com/p/08d57b2ff6e6</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[snowflake-connector]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[snowflake]]></category>
            <dc:creator><![CDATA[Soonmo Seong]]></dc:creator>
            <pubDate>Mon, 08 Jul 2024 05:14:08 GMT</pubDate>
            <atom:updated>2024-07-08T23:44:08.244Z</atom:updated>
            <content:encoded><![CDATA[<p>Snowflake의 Task를 AWS Lambda를 이용하면 필요한 조건에 따라서 실행할 수 있습니다. 그렇지만 AWS Lambda에서는 Snowflake Connector를 기본적으로 지원하지 않기 때문에 Custom Layer를 생성해서 함수가 잘 작동할 수 있도록 환경을 구성해야 합니다. 따라서 오늘은 Snowflake Connector(Python)용 AWS Lambda Custom Layer를 아래의 순서로 생성해보겠습니다.</p><ul><li>미리 알아두어야 할 사항</li><li>리눅스 환경에서 파일을 생성하기 위해서 Ubuntu EC2를 생성</li><li>Dependencies 설치 및 압축 파일 만들기</li><li>AWS Lambda Custom Layer 생성</li><li>Sample 코드 실행으로 정상적인 동작 확인하기</li></ul><h4>미리 알아두어야 할 사항</h4><p><a href="https://docs.aws.amazon.com/lambda/latest/dg/python-layers.html#python-layer-compatibility">Python용 AWS Lambda Custom Layer는 Amazon Linux에서 동작합니다</a>. 그래서 리눅스 환경에서 Zip File을 생성해야 합니다. 특히 개인 랩탑(Mac, Windows)에서 Zip File 생성 시 잘 동작하지 않습니다. 현시점(2024–07–08) 기준으로 Snowflake는 Python 버전 3.11을 추천합니다.</p><h4>리눅스 환경에서 파일을 생성하기 위해서 Ubuntu EC2를 생성</h4><ul><li>인스턴스에서 Launch Instances를 클릭합니다</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nZY5rhvh6h89_QcftZSGeQ.png" /></figure><ul><li>이름을 넣고 우분투를 선택하고 key pair를 생성합니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*T8nXXqdSrkRPEfJlpWwCZA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*v72rPgbOLM0wcjIcmiJu6w.png" /></figure><ul><li>Connect to your instance를 클릭합니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RKgPNk2o7krXcoLMwIas1g.png" /></figure><ul><li>아래의 방법을 참고하여 생성된 EC2 인스턴스에 SSH를 통해서 접속합니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*hvgGSMDatZLctDSbdDFvFg.png" /></figure><h4>Dependencies 설치 및 압축 파일 만들기</h4><ul><li>접속한 SSH Client(Terminal)에서 아래의 코드를 실행하여 Dependency를 설치합니다.</li></ul><pre># sudo apt를 업데이트합니다<br>sudo apt update<br><br># python dependency를 설치하기 위해 pip를 설치합니다<br>sudo apt install pip<br><br># 압축파일을 만들기 위해 zip을 설치합니다.<br>sudo apt install zip<br><br># 디렉토리를 만들고 snowflake connector를 설치합니다.<br>mkdir -p temp/python<br>cd temp/python<br>pip3 install snowflake-connector-python -t .</pre><ul><li>압축 파일 만들기</li></ul><pre># zip 파일을 생성합니다<br>cd ..<br>zip -r9 ../snowflake-connector-python.zip .</pre><ul><li>로컬 폴더에 압축 파일 다운로드하기</li></ul><pre># 새로운 터미널에서 아래의 명령어를 실행합니다<br># pem키, EC2 디렉토리, 로컬 PC 디렉토리는 사용자의 상황에 맞게 변경합니다<br>scp -i &quot;snowflake_connector_ec2_key.pem&quot; ubuntu@ec2-3-36-67-138.ap-northeast-2.compute.amazonaws.com:/home/ubuntu/snowflake-connector-python.zip /Users/mzc01-ssm/Downloads snowflake-connector-python.zip</pre><h4>AWS Lambda Custom Layer 생성</h4><ul><li>Layers를 선택하고 Create layer를 클릭합니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W-LathiDBYfzQGFPjAf3Tw.png" /></figure><ul><li>이름을 기입하고 zip file을 업로드하고 생성합니다. 생성 후 ARN을 복사합니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*lvRC4_VC1eFWkKXSg75uZA.png" /></figure><h4>Sample 코드 실행으로 정상적인 동작 확인하기</h4><ul><li>함수를 생성합니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-87tKuZbftuL7Lht0rcHEg.png" /></figure><ul><li>함수 이름, 런타임을 설정하고 함수를 생성 완료합니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*p5V8ly1vmY-6v26xhj5tEg.png" /></figure><ul><li>Add a layer를 클릭하고 복사 된 ARN으로 Layer를 더합니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h6rPw0APvj3EOBdO-tRfYw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*-Rv_41pS3-N6Gd3zydq47Q.png" /></figure><ul><li>아래의 함수를 넣고 Deploy를 누릅니다.</li></ul><pre>import json<br>import snowflake.connector<br><br>conn = snowflake.connector.connect(<br>user=&#39;xxxxxxxxxxxxx&#39;,<br>password=&#39;xxxxxxxxxxxxx&#39;,<br>account=&#39;xxxxxxxxxxxxx&#39;,<br>warehouse=&#39;xxxxxxxxxxxxx&#39;,<br>database=&#39;xxxxxxxxxxxxx&#39;,<br>schema=&#39;xxxxxxxxxxxxx&#39;<br>)<br>cs = conn.cursor()<br>cs.execute(&#39;execute task mzc_test_task1&#39;)<br>one_row = cs.fetchone()<br><br>cs.close()<br>conn.close()<br>    <br>def lambda_handler(event, context):<br><br>    # TODO implement<br>    return {<br>        &#39;statusCode&#39;: 200,<br>        &#39;SnowflakeTaskStatus&#39;: one_row[0]<br>    }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2BIZnewbUQlFhZm2tYAoyg.png" /></figure><ul><li>Test를 눌러서 테스트를 생성하고 코드를 실행합니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tc_A-RC64Mw_fp4skJEPgA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*uwVL0_yauoyc3cuaHexgdQ.png" /></figure><ul><li>테스트 결과 정상적으로 Python Connector가 동작하고 있을 것을 확인할 수 있습니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E5dfRkj9WchG3gG91tpyXg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=08d57b2ff6e6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudvillains/snowflake-connector-python-%EC%9A%A9-aws-lambda-custom-layer-08d57b2ff6e6">Snowflake Connector(Python)용 AWS Lambda Custom Layer</a> was originally published in <a href="https://medium.com/cloudvillains">Cloud Villains</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Snowflake Arctic의 기술적 진보]]></title>
            <link>https://medium.com/cloudvillains/snowflake-arctic%EC%9D%98-%EA%B8%B0%EC%88%A0%EC%A0%81-%EC%A7%84%EB%B3%B4-f241a56f989c?source=rss-f88a078b557a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f241a56f989c</guid>
            <category><![CDATA[snowflake-arctic]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[스노우플레이크]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Soonmo Seong]]></dc:creator>
            <pubDate>Thu, 25 Apr 2024 02:02:57 GMT</pubDate>
            <atom:updated>2024-04-25T04:08:49.714Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*q99Rt-U61DEpQC_S.png" /></figure><p>어제 저녁 스노우플레이크는 자신만의 새로운 LLM을 발표했습니다. 많은 기술적 진보가 엿보이는 스노우플레이크의 새로운 LLM에 대해 알아보겠습니다. 이 글은 <a href="https://www.snowflake.com/blog/arctic-open-efficient-foundation-language-models-snowflake/">Snowflake Arctic 발표</a>를 참고하여 작성되었습니다.</p><p>Snowflake AI 연구팀은 비용 효율적으로 훈련된 기업 중심의 대형 언어 모델인 Snowflake Arctic를 오픈소스로 공개했습니다. 큰 2개의 특징은 아래와 같습니다.</p><ul><li>효율적인 지능: Arctic은 SQL 생성, 코딩 및 지침 따르기 벤치마크와 같은 기업 작업에서 뛰어난 성능을 발휘하며, 상당히 높은 컴퓨팅 예산으로 훈련된 오픈 소스 모델들보다도 우수한 성능을 보입니다. Arctic은 기업 니즈에 맞는 고품질 맞춤형 모델을 저렴한 비용으로 만들 수 있는 새로운 기준을 세웠습니다.</li><li>진정한 개방성: Arctic은 Apache 2.0 라이선스를 통해 가중치, 코드, 데이터 레시피 및 연구 통찰력에 대한 제한 없는 액세스를 제공합니다.</li></ul><p>Snowflake Arctic은 오늘 Hugging Face에서 이용 가능하며, 향후 며칠 동안 Snowflake Cortex, Amazon Web Services(AWS), Microsoft Azure, NVIDIA API 카탈로그, Lamini, Perplexity, Replicate 및 Together를 통해서도 제공될 예정입니다.</p><h3>믿을 수 없을 정도로 낮은 훈련비용으로 구현한 기업용 지능</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hwWCrDG186SodlOm.png" /></figure><p>Snowflake는 새로운 지표인 ‘기업 지능(Enterprise Intelligence)’을 소개합니다. 이 지표는 코딩(HumanEval+와 MBPP+), SQL 생성(Spider) 및 지침 따르기(IFEval)의 평균을 내어 계산됩니다. 이 지표를 근거로 훈련 비용을 비교해보면 Arctic은 다른 LLM과 비교하여 현저히 낮은 비용을 높은 인공지능을 확보했습니다. 특히 데이터브릭스와 비교해서 1/8 정도의 비용으로 더 나은 모델을 개발했습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RiHO0Rng9MSP-ZMh.png" /></figure><p>Arctic은 고유한 Dense-MoE 하이브리드 아키텍처를 활용하는데, 이는 10B 밀집 트랜스포머 모델과 잔차 128x3.66B MoE MLP를 결합하여 총 480B, 상위 2개의 게이팅을 통해 선택된 17B 활성 매개변수로 구성됩니다. 다시 말해 Arctic은 128개의 세분화된 전문가에 걸쳐 480B 매개변수를 펼치고, 상위 2개의 게이팅을 사용하여 17B의 활성 매개변수를 선택하도록 설계되었습니다. 최근의 전문가 수가 적은 MoE 모델과 비교하면, Arctic은 더 많은 매개변수와 전문가를 활용하여 최상위 수준의 지능을 발휘합니다.</p><p>하지만 Arctic은 약 200만 달러 미만의 훈련 컴퓨팅 비용(3,000 GPU 주 미만)으로 최상위 성능을 달성했는데, 이는 전문가들이 압축되어 있고 아키텍처/시스템 공동 설계 및 기업 중심 데이터 커리큘럼으로 훈련되었기 때문입니다.</p><h3>효율적인 추론</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rUyR6cncwnryeLh9.png" /></figure><p>작은 배치 크기에서 Arctic(활성 매개변수 17B)은 Code-Llama 70B보다 최대 4배, Mixtral 8x22B(활성 매개변수 44B)보다 최대 2.5배 적은 메모리 읽기가 가능합니다. FP8 양자화를 사용하면 Arctic을 단일 GPU 노드에 탑재할 수 있습니다. 아직 완전히 최적화되지는 않았지만, 배치 크기 1에서 Arctic의 처리량은 초당 70개 이상의 토큰으로 효과적인 대화형 서비스가 가능합니다. 배치 크기가 상당히 증가하면 Arctic은 CodeLlama 70B와 Llama 70B보다 4배 적은 컴퓨팅만 필요합니다.</p><h3>진정한 개방성</h3><p>Snowflake의 개방성은 단순히 가중치와 코드의 공개를 넘어섭니다. Snowflake는 사전 훈련, 미세 조정, 모델링, 데이터, 시스템 등에 대한 연구 통찰력을 공유하는 포괄적인 ‘Cookbook’을 공개하여 효율적으로 세계 수준의 MoE 모델을 구축할 수 있도록 돕습니다.</p><p>요약하자면, Arctic은 기업 사용 사례에 맞는 개방적이고 비용 효율적이며 우수한 성능의 언어 모델을 대표하는 중대한 진전입니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f241a56f989c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudvillains/snowflake-arctic%EC%9D%98-%EA%B8%B0%EC%88%A0%EC%A0%81-%EC%A7%84%EB%B3%B4-f241a56f989c">Snowflake Arctic의 기술적 진보</a> was originally published in <a href="https://medium.com/cloudvillains">Cloud Villains</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Technical Summary of Snowflake Arctic]]></title>
            <link>https://medium.com/cloudvillains/technical-summary-of-snowflake-arctic-1f66f4d7a03d?source=rss-f88a078b557a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f66f4d7a03d</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[enterprise]]></category>
            <category><![CDATA[arctic]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Soonmo Seong]]></dc:creator>
            <pubDate>Thu, 25 Apr 2024 01:44:11 GMT</pubDate>
            <atom:updated>2024-04-25T02:17:13.579Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, <a href="https://www.snowflake.com/blog/arctic-open-efficient-foundation-language-models-snowflake/">Snowflake Arctic announcement</a> is summaried.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wzHKkEyfkKK00rMD.png" /></figure><p><a href="https://www.snowflake.com/blog/authors/snowflake-ai-research/">Snowflake AI Research</a> introduces Snowflake Arctic, a top-tier enterprise-focused large language model that pushes the frontiers of cost-effective training and openness.</p><ul><li>Efficiently Intelligent: Arctic excels at enterprise tasks like SQL generation, coding, and instruction following benchmarks, even outperforming open source models trained with significantly higher compute budgets. Arctic sets a new baseline for cost-effective training, enabling Snowflake customers to create high-quality custom models for enterprise needs at low cost.</li><li>Truly Open: Arctic has an open Apache 2.0 license providing ungated access to weights, code, data recipes, and research insights.</li></ul><p>Snowflake Arctic is available from Hugging Face today or via your model garden or catalog of choice, including Snowflake Cortex, Amazon Web Services (AWS), Microsoft Azure, NVIDIA API catalog, Lamini, Perplexity, Replicate and Together over the coming days.</p><h3>Enterprise Intelligence at Incredibly Low Training Cost</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lw3ZrQscG-H2vwuw.png" /></figure><p>Snowflake introduces a new metric, Enterprise Intellegence. This metric takes an average of Coding (HumanEval+ and MBPP+), SQL Generation (Spider) and Instruction following (IFEval). Arctic achieves the highest score of Enterprise Intelligence while Snowflake trains Arctic at the minimum cost. Especially, DataBricks almost spends 8 times with lower Enterprise Intelligence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Vyo0I7GE2L_m8GgI.png" /></figure><p>Arctic utilizes a unique Dense-MoE Hybrid architecture, which combines a 10B dense transformer model with a residual 128×3.66B MoE MLP resulting in 480B total and 17B active parameters chosen using a top-2 gating. In other words, Arctic is designed to have 480B parameters spread across 128 fine-grained experts and uses top-2 gating to choose 17B active parameters. Compared with recent MoE’s with fewer experts, Arctic leverages more parameters and experts to achieve top-tier intelligence.</p><p>However, Arctic achieves top-tier performance while using roughly under $2 million in training compute (less than 3K GPU weeks) because its experts are condensed and it’s trained with architecture/system co-design, and an enterprise-focused data curriculum.</p><h3>Efficient Inference</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-t6CZoR50vdsuQhx.png" /></figure><p>At a small batch size, Arctic (17B active parameters) can have up to 4x less memory reads than Code-Llama 70B, and up to 2.5x less than Mixtral 8x22B (44B active parameters). With FP8 quantization, we can fit Arctic within a single GPU node. While far from fully optimized, at a batch size of 1, Arctic has a throughput of over 70+ tokens/second for effective interactive serving. As the batch size increases significantly , Arctic incurs 4x less compute than CodeLlama 70B and Llama 3 70B.</p><h3>Truly Open</h3><p>Snowflake’s openness goes beyond open weights and code. Snowflake releases a comprehensive “cookbook” that shares research insights on pre-training, fine-tuning, modeling, data, systems, and more to help build world-class MoE models efficiently.</p><p>In summary, Arctic represents a significant advancement in open, cost-effective, and capable language models tailored for enterprise use cases.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f66f4d7a03d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudvillains/technical-summary-of-snowflake-arctic-1f66f4d7a03d">Technical Summary of Snowflake Arctic</a> was originally published in <a href="https://medium.com/cloudvillains">Cloud Villains</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Summary of Paper 1: Phi-3 Technical Report — a highly capable language model locally on your phone]]></title>
            <link>https://medium.com/@soonmo.seong/summary-of-paper-1-phi-3-technical-report-a-highly-capable-language-model-locally-on-your-phone-e6df463a92f1?source=rss-f88a078b557a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6df463a92f1</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[phi-3]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Soonmo Seong]]></dc:creator>
            <pubDate>Wed, 24 Apr 2024 06:30:17 GMT</pubDate>
            <atom:updated>2024-04-24T06:30:17.456Z</atom:updated>
            <content:encoded><![CDATA[<h3>Summary of Paper 1: Phi-3 Technical Report — a highly capable language model locally on your phone</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*fhDpLlg6XgLhnU113-kdww.jpeg" /></figure><p>This blog will summarize the <a href="https://arxiv.org/pdf/2404.14219.pdf">tech report of a mini LLM</a> that <a href="https://azure.microsoft.com/en-us/blog/introducing-phi-3-redefining-whats-possible-with-slms/">Microsoft published</a> as an open source. This model can be deployed on iPhone and <strong>achieve the performance as Mixtral 8 * 7B and GPT-3.5</strong>. Let’t deep dive into <a href="https://huggingface.co/microsoft/Phi-3-mini-4k-instruct">Phi-3</a>.</p><p>===============================================================</p><h3>1 Introduction</h3><p>Phi-3-mini with 3.8B parameters is introduced and trained on 3.3T tokens. During the training, more advanced versions of the datasets that are used for Phi-2 were used. <strong>Even though Phi-3-mini can be deployed on an iPhone, it achieves the performance of Mixtral 8 * 7B and GPT-3.5.</strong></p><h3>2 Technical Specifications</h3><p>It has a transformer decoder architecture with the context length of 4k. However, Phi-3-mini-128k is also introduced with the context length of 128k.</p><p>Phi-3-mini has the similar block structures as llama-2 and uses the same tokenizer with vocabulary size of 32064, meaning that all the packages developed for llama-2 can be applied to Phi-3-mini.</p><p>Phi-3-small with 7B take use of tiktoken tokenizer, which is a better multilingual tokenizer. The vocabulary size and context length are 100,352 and 8k respectively. A grouped query attention is leveraged for minimizing KV cache footprint. And, this model is trained on an additional 10% multilingual data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*tdBRH76nFqjh5ZUUZLQsCA.png" /></figure><p>Phi-3-mini can be quantized to 4-bits, occupying around 1.8G memory. This quantized model can be deployed on iPhone 14 with A16 Bionic chip and running natively on-device. The inference speed is more than 12 tokens per second in an offline manner.</p><p>The sequence of works mentions in <a href="https://arxiv.org/pdf/2306.11644.pdf">“Textbooks Are All You Need”</a> is followed. Microsoft shows that this flow allows a small model with 3.8B to perform as much as GPT-3.5 and Mixtral. The dataset used is comprised of heavily filtered web data and synthetic LLM-generated data. The pre-training divided into two phases. Phase 1 aimed for getting more general knowledge with web sources. Phase 2 focused more on logical reasoning with synthetic data. Microsoft mainly focuses on the quality of data for the highly capable model with small amount of parameters.</p><p>Phi-3-medium with 14B is also trained using the same tokenizer and architecture of Phi-3-mini. But it has 40 heads and 40 layers with embedding dimension 5120.</p><p>Both supervised instruction fine-tuning and preference tuning with direct optimization preference are used, improving its chat capabilities, robustness and safety.</p><h3>3 Academic Benchmarks</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*UHLEo9yuYTHOBXFwkUs58w.png" /></figure><p>Microsoft compared to phi-2, Mistral-7b-v0.1, Mixtral-8x7b, Gemma 7B, Llama-3-instruct- 8b, and GPT-3.5.</p><h3>4 Safety</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*9CfgqxbzuRfVOjvVv3SOVQ.png" /></figure><p>Phi-3-mini was developed as per Microsoft’s responsible AI principles. This process resulted in significant decrease of harmful response rates. In addition, some benchmarks shows that the family of Phi-3-mini quite outperform other models in terms of safety.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*knm3smE7Ka7qLM0wGO9cyg.png" /></figure><h3>5 Weakness</h3><p>Phi-3-mini is fundamentally limited by its size for certain tasks. That is, this model doesn’t store more factual knowledge. However, this issue may be handled by RAG. Another weakness is that this model is restricted to English. Multilingual capability is still hard for small LLM’s. Furthermore, harmful content generation is remained for improvement while the use of carefully curated training data, targeted post-training and red-teaming insights alleviates it.</p><p>===============================================================</p><p>To sum up, The 3.8B parameter Phi-3-mini model</p><ul><li>achieves performance comparable to Mixtral 8 * 7B and GPT-3.5</li><li>supports 4k and 128k context length</li><li>uses Grouped query attention to minimizes KV cache footprint</li><li>uses 10% additional multilingual data</li><li>is quantized to 4-bits, occupying around 1.8GB of memory</li><li>runs natively on the iPhone 14’s A16 Bionic chip with an offline inference speed exceeding 12 tokens per second</li><li>shows improvement in chat capabilities, robustness, and safety</li><li>is developed according to Microsoft’s responsible AI principles</li><li>results in a significant decrease in harmful response rates</li><li>is fundamentally limited by its size for extensive factual knowledge storage, English model, and harmful content generation</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6df463a92f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[llama3에 대한 Andrej Karpathy의 생각]]></title>
            <link>https://medium.com/cloudvillains/llama3%EC%97%90-%EB%8C%80%ED%95%9C-andrej-karpathy%EC%9D%98-%EC%83%9D%EA%B0%81-b42c87386f45?source=rss-f88a078b557a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b42c87386f45</guid>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llama-3]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Soonmo Seong]]></dc:creator>
            <pubDate>Mon, 22 Apr 2024 04:15:07 GMT</pubDate>
            <atom:updated>2024-04-23T00:10:16.361Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eWJ0wCnF3nh3x9mx.jpeg" /><figcaption>by llama official github</figcaption></figure><p><a href="https://twitter.com/karpathy/status/1781028605709234613">Andrej Karpathy의 트윗</a>를 번역한 글입니다.</p><p>===============================================================</p><p><a href="https://ai.meta.com/blog/meta-llama-3/">llama3</a> 8B와 70B(Base 및 미세조정 버전 모두) 모델을 출시하며, 해당 모델 클래스에서 우수한 성능을 보이고 있습니다(하지만 순위가 발표되면 알게 될 것입니다). 400B 모델은 여전히 학습 중이지만, 이미 GPT-4 수준(예: MMLU 84.8 vs GPT-4 Turbo 86.5)에 근접하고 있습니다.</p><h3>Tokenizer</h3><p>토큰 수가 32K(llama 2)에서 <strong>128K(llama 3)</strong>로 4배 증가했습니다. 더 많은 토큰을 가지면 시퀀스 길이를 더 잘 압축할 수 있어, 15% 더 적은 토큰 수로 더 나은 downstream 성능을 볼 수 있습니다.</p><h3>Architecture</h3><p>Llama 2와 크게 변화가 없습니다. Llama 2에서는 큰 모델만 <strong>Grouped Query Attention(GQA)</strong>을 사용했지만, 이제 8B 모델을 포함한 모든 모델에서 GQA를 사용합니다. 이는 Attention의 KV 캐시 크기를 줄이는 파라미터 공유 기법입니다. 복잡성을 줄이고 최적화하는 좋은 수정안입니다.</p><ul><li>KV 캐시는 토큰 생성 시 계산되는 Key/Value 텐서를 GPU 메모리에 저장한 후 재사용합니다. 이로써 Key/Value 텐서가 재 계산 되는 것을 막아 연산량을 줄입니다.</li></ul><h3>Sequence Length</h3><p>최대 컨텍스트 윈도우 토큰 수가 8192로 증가했습니다. llama 1은 2048이고 llama 2는 4096입니다. 이 증가는 환영할 만하지만 요즘 기준(예: GPT-4 128K)에 비하면 작은 편입니다. <strong>많은 사람이 이 부분에서 더 많은 발전을 기대</strong>했을 것입니다. 추후 미세조정 버전에서 개선될지도 모르겠습니다.</p><h3>Training Data</h3><p>llama 2는 2조 개의 토큰으로 학습했지만, llama 3는 15조 개의 토큰 데이터 셋으로 학습했습니다. 이 데이터에는 품질 관리에 많은 노력을 기울였고, 코드 토큰이 4배, 30개 이상의 비 영어 언어 토큰이 5% 포함되어 있습니다. <strong>5%는 영어 대비 비영어 비중이 낮은 편이어서 대부분 영어 모델</strong>이지만, 비영어가 포함된 것은 바람직합니다.</p><h3>Scaling Laws</h3><p>특히 주목할 만한 점은, 8B 파라미터 모델에 15조 토큰이라는 매우 대규모 데이터 셋으로 학습한 것인데, 이는 일반적이지 않고 새로운 시도이며 환영할 만합니다. <a href="https://paperswithcode.com/method/chinchilla">Chinchilla</a> 기준으로 8B 모델의 ‘컴퓨팅 최적화’ 지점은 2,000억 토큰 정도입니다(해당 크기에서 모델 성능 대비 가성비만 따진다면). 그러나 llama 3는 이 지점을 75배 이상 초과하여 학습했습니다. 이는 이례적이지만, 저는 작고 다루기 쉬우며 추론이 용이한 매우 유능한 모델을 얻게 된 것을 매우 바람직하게 생각합니다. Meta에 따르면 이 지점에서도 모델이 ‘표준적인 의미에서 수렴하지 않았다’고 합니다. 즉, <strong>우리가 사용하는 LLM들은 수렴 지점에 훨씬 미치지 못하고 100~1000배 이상 부족하게 학습되어 있다는 의미</strong>입니다. 실제로 저는 사람들이 이 흐름을 계속 이어나가 더 작은 모델에 대해서도 장기간 훈련하고 공개하기를 정말 바랍니다.</p><h3>Systems</h3><p>llama 3는 400 TFLOPS 처리량으로 16K GPU에서 훈련되었다고 합니다. 세부 사항은 언급되지 않았지만, H100 GPU를 fp16 정밀도로 사용했다고 가정하면, NVIDIA 마케팅 자료에서 1,979 TFLOPS로 명시되어 있습니다. 하지만 우리 모두가 아는 것처럼 작은 별표(*희소성 포함)가 상당한 역할을 하고 있어 실제 TFLOPS는 약 990 정도라고 봐야 합니다. 왜 희소성을 FLOPS로 계산하는지 모르겠습니다. 어쨌든 중요한 건, <strong>400/990에서 약 40% 활용도를 보였다는 것</strong>인데, 이 규모에서 그렇게 나쁘지 않습니다! 이 수준에 이르기 위해서는 <strong>매우 견고한 엔지니어링</strong>이 필요합니다.</p><h3>TLDR</h3><p>매우 환영할 만한 llama 3 모델을 Meta에서 공개했습니다. 기초적인 부분에 충실하고, 견고한 시스템과 데이터 작업에 많은 시간을 할애하여 장기 학습 모델의 한계를 탐구했습니다. 또한 GPT-4 수준의 첫 오픈소스 모델이 될 수 있는 400B 모델이 기대됩니다. 많은 사람들이 더 긴 컨텍스트 길이를 요구할 것 같습니다. 개인적으로도, 교육 및 테스트, 임베디드 애플리케이션 등을 위해 8B보다 훨씬 작은 100M, 1B 규모의 모델도 매우 필요하다고 생각합니다.</p><p>===============================================================</p><p><a href="https://www.linkedin.com/in/andrej-karpathy-9a650716/"><strong>Andrej Karpathy</strong></a>의 트윗을 요약해보겠습니다.</p><ul><li>메타는 8B와 70B llama3 모델(기본 및 미세조정 버전)을 공개했으며, 각 모델 클래스에서 우수한 성능을 보입니다.</li><li>400B 모델도 계속 학습 중이며, 이미 GPT-4 수준에 근접하는 성능을 보이고 있습니다. 토크나이저의 토큰 수가 128K(Llama 3)로 4배 증가했습니다.</li><li>아키텍처는 Llama 2와 크게 변화가 없지만, 모든 모델에서 Grouped Query Attention(GQA) 기법을 적용했습니다.</li><li>최대 컨텍스트 윈도우 길이가 8192로 증가했습니다.</li><li>15조 토큰 데이터 셋으로 훈련했으며, 코드 데이터와 다국어 데이터의 비중이 늘었습니다. 그러나 여전히 영어모델이 라고 보는 것이 합당합니다.</li><li>작은 8B 모델에 대해 15조 토큰으로 16K GPU로 훈련했으며, 엔지니어링 측면에서 매우 안정적인 시스템입니다. 400B 모델이 GPT-4 수준의 첫 번째 오픈소스 모델이 될 것으로 기대됩니다.</li><li>더 작은 100M, 1B 수준의 모델도 필요할 것이라는 의견을 제시했습니다.</li><li>전반적으로 Llama 3는 높은 성능과 견고한 시스템, 대규모 고품질 데이터 셋 기반의 모델로 평가되며, 오픈소스 분야에서 매우 의미 있는 진전입니다.</li></ul><p>Andrej Karpathy는 llama3에 대해서 긍정적인 시각으로 바로 보고 있는 것을 알 수 있으며 많은 기술적 진보가 일어났다고 생각하고 있습니다. 다면 영어 이외의 언어에 대한 제약과 조금 더 작은 모델이 공개되었으면 한다는 의견도 피력하였습니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b42c87386f45" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudvillains/llama3%EC%97%90-%EB%8C%80%ED%95%9C-andrej-karpathy%EC%9D%98-%EC%83%9D%EA%B0%81-b42c87386f45">llama3에 대한 Andrej Karpathy의 생각</a> was originally published in <a href="https://medium.com/cloudvillains">Cloud Villains</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Snowflake Marketplace 무료 데이터로 회귀모델 개발하기(Snowpark)]]></title>
            <link>https://medium.com/cloudvillains/snowflake-marketplace-%EB%AC%B4%EB%A3%8C-%EB%8D%B0%EC%9D%B4%ED%84%B0%EB%A1%9C-%ED%9A%8C%EA%B7%80%EB%AA%A8%EB%8D%B8-%EA%B0%9C%EB%B0%9C%ED%95%98%EA%B8%B0-snowpark-7b9e683b68ab?source=rss-f88a078b557a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b9e683b68ab</guid>
            <category><![CDATA[snowpark]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[marketplaces]]></category>
            <dc:creator><![CDATA[Soonmo Seong]]></dc:creator>
            <pubDate>Tue, 16 Apr 2024 01:47:44 GMT</pubDate>
            <atom:updated>2024-04-16T01:47:44.917Z</atom:updated>
            <content:encoded><![CDATA[<p>뉴욕시 거주자들의 연간 총 소득을 예측하는 선형 회귀 모델을 개발하겠습니다. 이 단계별 블로그를 읽고 Snowflake에서 ML 모델 구축 워크플로를 구현할 수 있습니다. 자세히는 다음과 같습니다:</p><ul><li>Snowflake Marketplace에서 데이터 가져오기</li><li>Snowsight에서 데이터 쿼리하기</li><li>Snowpark를 통해 Snowflake에 연결하기</li><li>모델 학습 및 추론</li></ul><h3>Snowflake Marketplace에서 데이터 가져오기</h3><p>Snowflake Marketplace는 매우 유용한 곳이며, 무료 데이터셋을 활용할 수 있어 좋습니다. Cybersyn에서는 우편번호별 연간 소득 데이터를 무료로 제공하고 있습니다. Marketplace로 이동하여 Cybersyn을 검색해 보겠습니다. US Housing &amp; Real Estate Essentials 데이터셋을 볼 수 있을 것입니다. 이를 클릭하면 우리가 찾고 있는 데이터를 오른쪽 중간에서 확인할 수 있습니다.</p><ol><li>Snowflake Marketplace에 접속합니다.</li><li>Cybersyn을 검색합니다.</li><li>US Housing &amp; Real Estate Essentials 데이터셋을 클릭합니다.</li><li>오른쪽 중간 부분에서 우편번호별 연간 소득 데이터를 확인할 수 있습니다.</li></ol><p>이 데이터셋을 사용하면 우리가 이전에 만든 데이터셋과 동일한 정보를 얻을 수 있습니다. 따라서 이 무료 데이터셋을 활용하여 모델 학습 과정을 더욱 효율적으로 진행할 수 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5mTVm2STnuf_S7fO.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RlZjYPr45-rUD_sK.png" /></figure><h3>Snowsight에서 데이터 쿼리하기</h3><p>하나의 데이터셋만으로는 우리가 개발하고자 하는 모델을 만들기 어려울 것 같습니다. 따라서 아래의 SQL 코드를 통해 모델 학습을 위한 기본 데이터셋을 얻을 수 있습니다. 이 코드를 Snowsight SQL Worksheet에서 실행해 보세요.</p><pre>use database us_housing__real_estate_essentials;<br>use schema cybersyn;<br><br>-- create new york city income data<br>---------------------------------------------------------<br>create or replace database snowpark_ml_modeling;<br>create or replace table SNOWPARK_ML_MODELING.PUBLIC.nyc_zip_income<br>(<br>zip varchar,<br>year number,<br>annual_income number<br>)<br>as with nyc_zip as (<br>select id_zip, city, state, zip<br>from us_housing__real_estate_essentials.cybersyn.us_addresses<br>where state = &#39;NY&#39;<br>    and city = &#39;New York&#39;<br>group by id_zip, city, state, zip<br>) <br>select zip, year(date), value<br>from us_housing__real_estate_essentials.cybersyn.irs_individual_income_timeseries ii<br>join nyc_zip on (nyc_zip.id_zip = ii.geo_id)<br>where variable = &#39;Total_income_-_Amount,_AGI_bin:_Total&#39;<br>;<br>select * from snowpark_ml_modeling.public.nyc_zip_income<br>order by zip, year<br>;</pre><p>쿼리한 데이터셋을 미리 살펴보겠습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d0RIzVV5hTUfqbJH.png" /></figure><h3>Snowpark를 통해 Snowflake에 연결하기</h3><p>Snowpark는 Python을 지원하기 때문에 머신 러닝 시스템을 구축할 때 매우 유용한 도구입니다. 다음 섹션에서는 Python Snowpark를 주로 사용할 것입니다. Snowpark에서의 모든 작업은 Session에서 시작됩니다. 따라서 connection_parameters를 사용하여 세션을 생성합니다. XXXXXXXXXXXXX는 귀하의 계정, 사용자, 비밀번호로 대체하십시오.</p><pre>from snowflake.snowpark.session import Session<br>from snowflake.snowpark.types import IntegerType, FloatType<br>from snowflake.snowpark.functions import avg, sum, col, udf, call_udf, call_builtin, year, month<br>import streamlit as st<br>import pandas as pd<br><br># scikit-learn (install: pip install -U scikit-learn)<br>from sklearn.linear_model import LinearRegression<br># Session<br>connection_parameters = {<br>    &quot;account&quot;: &quot;XXXXXXXXXXXXX&quot;,<br>    &quot;user&quot;: &quot;XXXXXXXXXXXXX&quot;,<br>    &quot;password&quot;: &quot;XXXXXXXXXXXXX&quot;,<br>    &quot;role&quot;: &quot;ACCOUNTADMIN&quot;,<br>    &quot;warehouse&quot;: &quot;COMPUTE_WH&quot;,<br>    &quot;database&quot;: &quot;SNOWPARK_ML_MODELING&quot;,<br>    &quot;schema&quot;: &quot;PUBLIC&quot;<br>}<br>session = Session.builder.configs(connection_parameters).create()</pre><p>앞서 만든 기본 데이터셋을 쿼리해 보겠습니다. 이를 통해 Snowflake에 성공적으로 연결되었음을 확인할 수 있습니다. 출력 결과를 보면 다음과 같은 정보가 포함되어 있습니다:</p><ul><li>zip: 우편번호</li><li>year: 연도</li><li>annual_income: 연간 소득</li></ul><p>이 데이터를 사용하여 뉴욕시 거주자들의 연간 총 소득을 예측하는 선형 회귀 모델을 개발할 수 있습니다. Snowflake에 성공적으로 연결되었음을 확인할 수 있습니다. 다음 단계에서는 이 데이터를 사용하여 모델 학습을 진행하겠습니다.</p><pre>session.table(&quot;NYC_ZIP_INCOME&quot;).show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/0*mi-js4hTqMEk2Ekb.png" /></figure><h3>모델 학습 및 추론</h3><h4>Feature Engineering: One hot encoding</h4><p>우편번호는 숫자로 보이지만 실제로는 그렇지 않습니다. 따라서 ML 모델이 이해할 수 있도록 one-hot encoding을 사용하여 이 특징을 처리해야 합니다.</p><pre>df = session.table(&quot;NYC_ZIP_INCOME&quot;).to_pandas()<br><br># split X and y for training a regression model<br>X = df[[&#39;ZIP&#39;, &#39;YEAR&#39;]]<br>y = df[&#39;ANNUAL_INCOME&#39;]<br><br># one hot encoding for zip code because it&#39;s not a number<br>from sklearn.preprocessing import OneHotEncoder<br>ohe = OneHotEncoder()<br>ohe.fit(X[[&#39;ZIP&#39;]])<br>ohe_zip = ohe.transform(X[[&#39;ZIP&#39;]]).toarray()<br>transformed_df = pd.DataFrame(<br>    ohe_zip, <br>    columns=ohe.get_feature_names_out()<br>)<br>X = pd.concat([transformed_df, df[&#39;YEAR&#39;]], axis=1)</pre><p>이 코드에서는</p><ol><li>데이터프레임 df 를 X variables와 y variable로 분리하여 학습에 필요한 형태로 변환합니다.</li><li>그리고 OneHotEncoder를 사용하여 숫자 인덱스를 one-hot 인코딩된 벡터로 변환합니다.</li><li>원본 우편번호 열을 삭제하여 중복을 피합니다.</li></ol><p>이렇게 처리된 2개의 데이터프레임으로 선형 회귀 모델을 학습할 수 있습니다.</p><h4>Model Training</h4><p>Scikit-learn(sklearn)을 사용하여 선형 회귀 모델을 학습하는 방법입니다. 이 코드에서는 다음과 같은 작업을 수행합니다:</p><ol><li>sklearn의 LinearRegression 클래스를 사용하여 선형 회귀 모델을 생성합니다.</li><li>model.fit()을 사용하여 모델을 학습합니다</li></ol><p>이렇게 sklearn을 사용하여 학습한 선형 회귀 모델을 다음 단계에서는 예측에 활용합니다.</p><pre># fit the regression model<br>regr = LinearRegression()<br>regr.fit(X, y)]</pre><h4>추론</h4><p>예측 함수는 아래와 같습니다. 우리는 훈련 데이터셋을 변형한 것과 같이 zip_code와 year와 같은 입력 데이터를 변형해야 합니다. 우편번호 10001번 지역 거주자들의 2025년 총 소득은 약 USD 3,045,585,620입니다.</p><pre># create a prediction function<br>def annual_income_predictor(zip_code, year):<br>    # one hot encoding for zip code<br>    input = pd.DataFrame(ohe.transform([[str(zip_code)]]).toarray())<br>    # concat one hot encoded zip code with year<br>    input = pd.concat([input, pd.DataFrame([year])], axis=1)<br>    return float(regr.predict(input))<br><br># result = 3045585629.5694885<br>annual_income_predictor(10001, 2025)</pre><h3>결론</h3><p>Snowflake Data Cloud 플랫폼 하에서 sklearn과 snowpark를 사용하여 ML 모델을 생성하는 과정을 간단히 요약하겠습니다.</p><ol><li>Snowsight SQL Worksheet에서 모델 학습을 위한 기본 데이터셋을 생성합니다.</li><li>Python Snowpark를 사용하여 Snowflake에 연결합니다. snowflake.snowpark.session.Session을 생성하여 Snowflake와의 연결을 설정합니다.</li><li>데이터셋을 읽어들여 전처리를 수행합니다. OneHotEncoder를 사용하여 우편번호 열을 one-hot encoding합니다.</li><li>sklearn.linear_model.LinearRegression 모델을 생성하고 학습시킵니다. fit()을 사용하여 모델을 학습합니다. 이 과정에서 블로그의 간결함을 위해 모델을 평가하고 검증하는 과정을 생략했습니다.</li><li>학습된 모델을 사용하여 새로운 데이터에 대한 예측을 수행합니다. predict_income() 함수를 정의하여 입력 데이터를 변형하고 모델의 예측 결과를 반환합니다. 우편번호 10001번 지역의 2025년 예측 소득을 출력합니다.</li></ol><p>이와 같은 과정을 통해 Snowflake Data Cloud 플랫폼에서 sklearn과 snowpark를 사용하여 ML 모델을 구축할 수 있습니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b9e683b68ab" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudvillains/snowflake-marketplace-%EB%AC%B4%EB%A3%8C-%EB%8D%B0%EC%9D%B4%ED%84%B0%EB%A1%9C-%ED%9A%8C%EA%B7%80%EB%AA%A8%EB%8D%B8-%EA%B0%9C%EB%B0%9C%ED%95%98%EA%B8%B0-snowpark-7b9e683b68ab">Snowflake Marketplace 무료 데이터로 회귀모델 개발하기(Snowpark)</a> was originally published in <a href="https://medium.com/cloudvillains">Cloud Villains</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>