or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

chat-interface.mdclient-management.mddocument-prompt-template.mdembeddings.mdevaluation.mdexplanations.mdindex.mdprompt-construction.mdsteering.mdstructured-output.mdtext-completion.mdtokenization.mdtranslation.mdutilities.md

steering.mddocs/

0

# Steering & Content Control

1

2

Create and use steering concepts to guide model behavior and output style. Steering allows fine-grained control over how models generate content by defining positive and negative examples.

3

4

## Capabilities

5

6

### Steering Paired Examples

7

8

Define positive and negative examples to teach the model desired behavior patterns.

9

10

```python { .api }

11

class SteeringPairedExample:

12

negative: str

13

positive: str

14

15

def __init__(self, negative: str, positive: str):

16

"""

17

Paired example showing negative and positive versions of content.

18

19

Parameters:

20

- negative: Example of undesired style or content

21

- positive: Example of desired style or content

22

"""

23

24

def to_json(self) -> Mapping[str, Any]:

25

"""Convert example to JSON format."""

26

```

27

28

### Steering Concept Creation

29

30

Create steering concepts from paired examples that can be applied to completion requests.

31

32

```python { .api }

33

class SteeringConceptCreationRequest:

34

examples: List[SteeringPairedExample]

35

36

def __init__(self, examples: List[SteeringPairedExample]):

37

"""

38

Creates a new steering concept that can be used in completion requests.

39

40

Parameters:

41

- examples: A list of SteeringPairedExample objects showing desired transformations

42

"""

43

44

def to_json(self) -> Mapping[str, Any]:

45

"""Convert request to JSON format."""

46

```

47

48

### Steering Concept Response

49

50

Response containing the created steering concept identifier.

51

52

```python { .api }

53

class SteeringConceptCreationResponse:

54

id: str

55

56

def __init__(self, id: str):

57

"""

58

Response from steering concept creation.

59

60

Attributes:

61

- id: Unique identifier for the created steering concept

62

"""

63

64

@staticmethod

65

def from_json(json: Dict[str, Any]) -> SteeringConceptCreationResponse:

66

"""Create response from JSON data."""

67

```

68

69

### Steering Methods

70

71

Create and manage steering concepts using synchronous and asynchronous clients.

72

73

```python { .api }

74

def create_steering_concept(

75

self,

76

request: SteeringConceptCreationRequest

77

) -> SteeringConceptCreationResponse:

78

"""

79

Create a new steering concept.

80

81

Parameters:

82

- request: Steering concept configuration with examples

83

84

Returns:

85

SteeringConceptCreationResponse with concept ID

86

"""

87

88

async def create_steering_concept(

89

self,

90

request: SteeringConceptCreationRequest

91

) -> SteeringConceptCreationResponse:

92

"""

93

Create a new steering concept (async).

94

95

Parameters:

96

- request: Steering concept configuration with examples

97

98

Returns:

99

SteeringConceptCreationResponse with concept ID

100

"""

101

```

102

103

### Usage Examples

104

105

Creating and using steering concepts for content control:

106

107

```python

108

from aleph_alpha_client import (

109

Client,

110

SteeringPairedExample,

111

SteeringConceptCreationRequest,

112

CompletionRequest,

113

Prompt

114

)

115

116

client = Client(token="your-api-token")

117

118

# Create steering examples for casual vs formal language

119

examples = [

120

SteeringPairedExample(

121

negative="I appreciate your valuable feedback on this matter.",

122

positive="Thanks for the real talk, fam."

123

),

124

SteeringPairedExample(

125

negative="The financial projections indicate significant growth potential.",

126

positive="Yo, these numbers are looking mad stacked!"

127

),

128

SteeringPairedExample(

129

negative="Please consider attending our upcoming meeting.",

130

positive="Come hang out at our meetup if you're free!"

131

),

132

SteeringPairedExample(

133

negative="We should proceed with caution regarding this decision.",

134

positive="Let's not rush into this, just saying."

135

)

136

]

137

138

# Create steering concept

139

steering_request = SteeringConceptCreationRequest(examples=examples)

140

steering_response = client.create_steering_concept(steering_request)

141

142

print(f"Created steering concept: {steering_response.id}")

143

144

# Use steering concept in completion

145

completion_request = CompletionRequest(

146

prompt=Prompt.from_text("Write a professional email about project delays"),

147

maximum_tokens=150,

148

temperature=0.7,

149

steering_concepts=[steering_response.id] # Apply casual style steering

150

)

151

152

response = client.complete(completion_request, model="luminous-extended")

153

print("Steered completion:")

154

print(response.completions[0].completion)

155

156

# Create steering for technical explanation style

157

tech_examples = [

158

SteeringPairedExample(

159

negative="Machine learning is when computers learn things automatically.",

160

positive="Machine learning algorithms optimize parameters through iterative training on labeled datasets to minimize loss functions."

161

),

162

SteeringPairedExample(

163

negative="AI helps solve problems by being smart.",

164

positive="Artificial intelligence systems utilize pattern recognition, statistical inference, and computational optimization to process complex data."

165

),

166

SteeringPairedExample(

167

negative="The program runs faster now.",

168

positive="The optimized algorithm demonstrates improved computational complexity from O(n²) to O(n log n)."

169

)

170

]

171

172

tech_steering_request = SteeringConceptCreationRequest(examples=tech_examples)

173

tech_steering_response = client.create_steering_concept(tech_steering_request)

174

175

# Apply technical steering

176

tech_completion = CompletionRequest(

177

prompt=Prompt.from_text("Explain how neural networks work"),

178

maximum_tokens=200,

179

temperature=0.3,

180

steering_concepts=[tech_steering_response.id]

181

)

182

183

tech_response = client.complete(tech_completion, model="luminous-extended")

184

print("Technical explanation:")

185

print(tech_response.completions[0].completion)

186

187

# Combine multiple steering concepts

188

mixed_completion = CompletionRequest(

189

prompt=Prompt.from_text("Describe the benefits of cloud computing for small businesses"),

190

maximum_tokens=180,

191

steering_concepts=[

192

steering_response.id, # Casual tone

193

tech_steering_response.id # Technical depth

194

]

195

)

196

197

mixed_response = client.complete(mixed_completion, model="luminous-extended")

198

print("Multi-steered completion (casual + technical):")

199

print(mixed_response.completions[0].completion)

200

201

# Async steering concept creation

202

import asyncio

203

204

async def create_async_steering():

205

async with AsyncClient(token="your-api-token") as client:

206

examples = [

207

SteeringPairedExample(

208

negative="This is a good solution to the problem.",

209

positive="This solution elegantly addresses the core requirements while maintaining scalability."

210

)

211

]

212

213

request = SteeringConceptCreationRequest(examples=examples)

214

response = await client.create_steering_concept(request)

215

return response.id

216

217

concept_id = asyncio.run(create_async_steering())

218

print(f"Async created concept: {concept_id}")

219

```