← Back to list

How to Set Up Snowflake’s Enterprise LLM Artic in Snowflake using Replicate

Snowflake Artic

Mebin Joy · 2024-04-27 06:57 · 11 claps · 2.1 min read
#snowflake #snowflake-arctic #replicate #llm
Open on Medium ↗
Wiki topics: LLM · Large Language Models 🔧 · Data Engineering

How to Set Up Snowflake’s Enterprise LLM Artic in Snowflake using Replicate

Snowflake Artic

Snowflake Artic

This article serves as a comprehensive guide on configuring and utilizing Artic in Snowflake without relying on Cortex, which is presently in private preview. By leveraging Replicate as the API provider for Artic and employing some Python scripting along with Snowflake’s adaptable architecture, you can seamlessly integrate Artic into your Snowflake environment.

Step 1: Sign Up for Replicate

Begin by signing up for Replicate using the provided link: https://replicate.com/snowflake/snowflake-arctic-instruct. You can conveniently use your GitHub account for registration. After signing up, navigate to your account and copy the Replicate token provided. With this token, your Replicate setup is complete. Additionally, you can experiment with Artic via the following link: [https://replicate.com/snowflake/snowflake-arctic-instruct].

Step 2: Configure Network Rules

Execute the following command to configure the network rule:

CREATE OR REPLACE NETWORK RULE REPLICATE_RULE TYPE = ‘HOST_PORT’ MODE= ‘EGRESS’ VALUE_LIST = (‘api.replicate.com’);

This command establishes the network rule necessary for Snowflake to communicate with Replicate. Further details about network rules can be found here.

Step 3: Configure Replicate Token

Utilize the following command to configure the Replicate token. Ensure to replace <token> with your actual token:

CREATE OR REPLACE SECRET REPLICATE_KEY TYPE = GENERIC_STRING SECRET_STRING = ‘<token>’;

For more information regarding secrets, refer to the Snowflake documentation on secrets.

Step 4: Create External Access Integrations

Execute the following command to create external access integrations:

CREATE OR REPLACE EXTERNAL ACCESS INTEGRATION REPLICATE_ACCESS_INTEGRATION ALLOWED_NETWORK_RULES = (REPLICATE_RULE) ALLOWED_AUTHENTICATION_SECRETS = (REPLICATE_KEY) ENABLED = true;

This step enables the connection to Replicate from Snowflake.

Step 5: Create a Python UDF

Next, create a Python UDF for accessing Artic from Replicate. Here’s the code:

CREATE OR REPLACE FUNCTION ARTIC(query varchar) RETURNS STRING LANGUAGE PYTHON RUNTIME_VERSION = 3.10 HANDLER = ‘artic’ EXTERNAL_ACCESS_INTEGRATIONS = (REPLICATE_ACCESS_INTEGRATION) SECRETS = (‘REPLICATE_API_TOKEN’ = REPLICATE_KEY) PACKAGES = (‘requests’) AS $$ import requests import _snowflake

REPLICATE_API_TOKEN = _snowflake.get_generic_secret_string(‘REPLICATE_API_TOKEN’)

*def artic(query:str) :

Define the request payload

request_payload = { “input”: { “prompt”: query, “temperature”: 0.2, “stop_sequences”: ‘im_end’ } }*

# Make the API request response = requests.post( “https://api.replicate.com/v1/models/snowflake/snowflake-arctic-instruct/predictions", headers={ “Authorization”: f”Bearer {REPLICATE_API_TOKEN}”, “Content-Type”: “application/json” }, json=request_payload )

# Extract the prediction prediction = response.json() pred_id = prediction[‘id’] preds = requests.get(url=f”https://api.replicate.com/v1/predictions/{pred_id}",headers={ “Authorization”: f”Bearer {REPLICATE_API_TOKEN}”, “Content-Type”: “application/json” }) while preds.json()[‘status’] != ‘succeeded’: preds = requests.get(url=f”https://api.replicate.com/v1/predictions/{pred_id}”,headers={ “Authorization”: f”Bearer {REPLICATE_API_TOKEN}”, “Content-Type”: “application/json” }) final_res = preds.json() return(‘’.join(final_res[‘output’]))

$$;

Step 6: Verification

You have now successfully enabled Artic in your Snowflake instance as a function. Verify its functionality by executing the following command:

SELECT ARTIC(‘Introduce yourself’);

By following these steps, you can integrate Artic into your Snowflake environment seamlessly. Stay connected for more insights and explorations into Snowflake Artic.

Here’s a link to learn more about Snowflake Artic — https://www.snowflake.com/blog/arctic-open-efficient-foundation-language-models-snowflake/


메타데이터
post_id
06362e6c22bb
slug
how-to-set-up-snowflakes-enterprise-llm-artic-in-snowflake-without-snowflake-cortex-06362e6c22bb
url
https://medium.com/@mebinjoy/how-to-set-up-snowflakes-enterprise-llm-artic-in-snowflake-without-snowflake-cortex-06362e6c22bb
canonical_url
https://medium.com/@mebinjoy/how-to-set-up-snowflakes-enterprise-llm-artic-in-snowflake-without-snowflake-cortex-06362e6c22bb
author_url
https://medium.com/@mebinjoy
status
ok
fetched_at
2026-07-16 00:55:23